src/proto2/NetworkClient.hh
author terom
Thu, 20 Nov 2008 19:25:56 +0000
branchno-netsession
changeset 36 785d220fc6b7
parent 35 e21cfda0edde
permissions -rw-r--r--
...
#ifndef NETWORKCLIENT_HH
#define NETWORKCLIENT_HH

#include "Network.hh"
#include "GameState.hh"
#include "NetworkSession.hh"
#include "NetworkObject.hh"

// forward-declare
class NetworkClientLocalPlayer;
class NetworkClientRemotePlayer;

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

    private:
        NetworkSession netsession;
        NetworkNode *server;

        NetworkObject_ClientController netobjs;
        
    public:
        NetworkClient (GameState &state, const NetworkAddress &connect_to);

    private:
        void on_create (NetworkObject_Client *obj, NetworkMessageID msg_id, NetworkPacket &pkt);

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

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

        CL_SlotContainer slots;
        
        NetworkObject_Client *obj;

    public:
        NetworkClientLocalPlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
        
        virtual void applyForce (Vector force, uint16_t dt);
    
    private:
        void on_position (NetworkPacket &pkt);
};

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

        NetworkObject_Client *obj;

    public:
        NetworkClientRemotePlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
    
    private:
        void on_position (NetworkPacket &pkt);

        void on_quit (NetworkPacket &pkt);
};

#endif