--- a/src/Network/Client.hh Tue Jan 20 23:24:04 2009 +0200
+++ b/src/Network/Client.hh Tue Jan 20 23:30:18 2009 +0200
@@ -8,6 +8,7 @@
*/
// forward-declare
+class NetworkClientConnect;
class NetworkClient;
class NetworkClientLocalPlayer;
class NetworkClientRemotePlayer;
@@ -27,7 +28,7 @@
* The NetworkClient
*/
NetworkClient &client;
-
+
public:
/**
* Control objects on the given client using the client.netsession's NETCHAN_CORE channel
@@ -86,12 +87,10 @@
*/
GameState &state;
- CL_SlotContainer slots;
-
/**
* The connect()-mode NetworkSession
*/
- NetworkSession netsession;
+ NetworkSession &netsession;
/**
* The server NetworkNode from Netsession::connect
@@ -103,6 +102,8 @@
*/
NetworkClientController controller;
+ CL_SlotContainer slots;
+
public:
/**
* Create a NetworkClient with the given GameState, connecting a server on the given NetworkEndpoint
@@ -111,7 +112,48 @@
* @param state the GameState to use
* @param connect_to the address to connect to
*/
- NetworkClient (Engine &engine, GameState &state, const NetworkEndpoint &connect_to);
+ NetworkClient (Engine &engine, GameState &state, NetworkSession &netsession, NetworkNode *server);
+
+ public:
+ /**
+ * Called by NetworkClientRemotePlayer when they get disconnected. Doesn't do anything currently
+ */
+ void player_quit (NetworkClientRemotePlayer *player);
+};
+
+/**
+ * This handles the actual connection process to the server, and handles the initial data from the server. Once the
+ * Engine has a game running, we can create the actual NetworkClient object.
+ */
+class NetworkClientConnect {
+ protected:
+ /**
+ * The Engine we are running under
+ */
+ Engine &engine;
+
+ /**
+ * The NetworkSession we are using
+ */
+ NetworkSession netsession;
+
+ /**
+ * The server we've connected to
+ */
+ NetworkNode *server;
+
+ /**
+ * The NetworkClient that we eventually create
+ */
+ NetworkClient *client;
+
+ CL_SlotContainer slots;
+
+ public:
+ /**
+ * Begin the connection process. Once it is complete, we will callback to Engine::networkClientConnected
+ */
+ NetworkClientConnect (Engine &engine, const NetworkEndpoint &connect_to);
protected:
/**
@@ -123,12 +165,11 @@
* Receive the NETCHAN_TERRAIN_ARRAY message from the server and apply it to our GameState::world terrain
*/
void on_terrain_array (NetworkPacketInput &pkt, NetworkNode *node);
-
- public:
+
/**
- * Called by NetworkClientRemotePlayer when they get disconnected. Doesn't do anything currently
+ * Finished connecting
*/
- void player_quit (NetworkClientRemotePlayer *player);
+ void connectDone (Terrain *terrain);
};
/**