src/proto2/NetworkClient.hh
author terom
Sat, 08 Nov 2008 21:25:56 +0000
changeset 23 8d802b573cf0
parent 22 b70d30e1b0fe
child 24 b81cb670e6b2
permissions -rw-r--r--
fixed more network code, there's actually a high probability of it working now
#ifndef NETWORKCLIENT_HH
#define NETWORKCLIENT_HH

#include "Network.hh"
#include "GameState.hh"

// forward-declare
class NetworkClientRemotePlayer;

class NetworkClient : public NetworkCore {
	private:
		CL_NetComputer server;
		
	public:
		NetworkClient (GameState &state, const CL_IPAddress &connect_to);

	private:
		void on_create_object (CL_NetObject_Client &obj, int msg_type, CL_NetPacket &pkt);

		void on_server_hello (CL_NetObject_Client &obj, CL_NetPacket &pkt);
		void on_player_info (CL_NetObject_Client &obj, CL_NetPacket &pkt);
		void on_player_join (CL_NetObject_Client &obj, CL_NetPacket &pkt);
	
	public:
		void player_quit (NetworkClientRemotePlayer *player);
};

class NetworkClientLocalPlayer : public LocalPlayer {
	private:
		NetworkClient &client;

		CL_SlotContainer slots;

		CL_NetObject_Client obj;

	public:
		NetworkClientLocalPlayer (NetworkClient &client, CL_NetObject_Client &obj, Coordinate initial_position);
		
		virtual void move (PositionDelta d);
	
	private:
		void on_position (CL_NetPacket &pkt);
};

class NetworkClientRemotePlayer : public RemotePlayer {
	private:
		NetworkClient &client;
		
		CL_SlotContainer slots;

		CL_NetObject_Client obj;

	public:
		NetworkClientRemotePlayer (NetworkClient &client, CL_NetObject_Client &obj, Coordinate initial_position);
	
	private:
		void on_position (CL_NetPacket &pkt);

		void on_quit (CL_NetPacket &pkt);
};

#endif