src/proto2/NetworkClient.hh
author terom
Sun, 09 Nov 2008 22:02:03 +0000
changeset 26 5685602aeb9c
parent 25 af75a1894a32
child 35 e21cfda0edde
child 54 b8b043ba0abd
permissions -rw-r--r--
it works \o/
#ifndef NETWORKCLIENT_HH
#define NETWORKCLIENT_HH

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

// forward-declare
class NetworkClientLocalPlayer;
class NetworkClientRemotePlayer;

class NetworkClient : public NetworkCore {
    friend class NetworkClientLocalPlayer;
    friend class NetworkClientRemotePlayer;

    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 bool 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