Show connectstate.h syntax highlighted
/***************************************************************************
connectstate.h
-------------------
begin : Wed Feb 2 2005
copyright : (C) 2005 by Brendon Lloyd Higgins
email : bh_doc@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef CONNECTSTATE_H_INCLUDED
#define CONNECTSTATE_H_INCLUDED
#include <clientstate.h>
#include <ClanLib/network.h>
class LoadState;
class PlayerClient;
/**
* List type containing the players.
*/
typedef std::list<PlayerClient*> PlayerList;
/**
* Handles connection and handshake, player info, and waiting for the server to
* start.
*/
class ConnectState: public ClientState {
public:
/**
* Constructor.
*/
ConnectState(const CL_IPAddress& serv);
/**
* Destructor.
*/
virtual ~ConnectState();
virtual ClientState* go(Client* client);
private:
/**
* Handle a server welcome.
*/
void onNetHandshake(CL_NetStream& stream);
/**
* Handle the game start.
*/
void onStart(CL_NetStream& stream);
/**
* Handle unexpected disconnect.
*/
void onDisconnect(CL_NetComputer& computer);
/**
* Admin message recieved.
*/
void onAdmin(CL_NetPacket& packet, CL_NetComputer &computer);
/**
* Create a player.
*/
void onPlayerCreate(CL_InputSource& is);
/**
* Process a player message.
*/
void onPlayerMessage(CL_NetPacket& p);
/**
* Remove a player from the list.
*/
void onPlayerRemove(CL_NetPacket& p);
/**
* The address and port of the server.
*/
CL_IPAddress serverIP;
/**
* The netsession.
*/
CL_NetSession* netsession;
/**
* The server.
*/
CL_NetComputer server;
/**
* Slot used to signal the next step in game state construction.
* The first step is handshaking. The second step is game start.
*/
CL_Slot* nextSlot;
/**
* The list of players.
*/
PlayerList* players;
/**
* The local player.
*/
PlayerClient* me;
/**
* States.
*/
enum State {
AWAIT_HANDSHAKE,
AWAIT_START,
FAIL
};
/**
* Current state.
*/
State state;
/**
* The next state class to come after this one.
*/
LoadState* next;
};
#endif /* ndef CONNECTSTATE_H_INCLUDED */
See more files for this project here