src/proto2/NetworkServer.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 NETWORKSERVER_HH
#define NETWORKSERVER_HH

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

#include <list>
#include <map>
#include <ClanLib/core.h>

// forward-declare
class NetworkServerPlayer;

class NetworkServer : public NetworkCore {
	friend class NetworkServerPlayer;

	private:
		uint16_t pid_pool;
	
	public:
		std::map<CL_NetComputer, NetworkServerPlayer*> players;

	public:
		NetworkServer (GameState &state, const std::string &listen_port);

	private:
		void on_connect (CL_NetComputer &computer);
		void on_disconnect (CL_NetComputer &computer);

	
};

class NetworkServerPlayer : public RemotePlayer {
	private:
		NetworkServer &server;
		CL_NetComputer &computer;
		CL_NetObject_Server obj;

		CL_SlotContainer slots;

		uint16_t pid;
		
	public:
		NetworkServerPlayer (NetworkServer &server, CL_NetComputer &computer, uint16_t pid);

		void disconnected (void);

	private:
		void on_move (CL_NetComputer &from, CL_NetPacket &pkt);

		void send_position_update (void);
};

#endif