src/proto2/NetworkServer.hh
author terom
Sun, 09 Nov 2008 20:40:46 +0000
changeset 24 b81cb670e6b2
parent 23 8d802b573cf0
child 32 2ff929186c90
child 89 825c4613e087
permissions -rw-r--r--
the great :retab
#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