src/proto2/Network.hh
author terom
Sun, 09 Nov 2008 21:51:13 +0000
changeset 25 af75a1894a32
parent 24 b81cb670e6b2
child 32 2ff929186c90
child 66 1415a2d45686
permissions -rw-r--r--
simple proto *almost* works
#ifndef NETWORK_HH
#define NETWORK_HH

#include "NetworkConfig.hh"
#include "GameState.hh"

#include <ClanLib/network.h>

class NetworkCore {
    protected:
        GameState &state;

        CL_SlotContainer slots;

        CL_NetSession netsession;

        CL_NetObject_Controller netobjs;
        
        // constructor
        NetworkCore (GameState &state) : state(state), netsession(NETWORK_APP_NAME), netobjs(&netsession, NETWORK_NETOBJ_CHAN) { }
};

enum NetworkMessage {
    NETMSG_PACKET_INVALID   = 0x00,

    /*
     * You have joined the game:
     *
     *  uint32_t x
     *  uint32_t y
     */
    NETMSG_SERVER_HELLO = 0x0100,

    /*
     * New client has connected to server:
     *
     *  uint32_t x
     *  uint32_t y
     */
    NETMSG_PLAYER_JOIN  = 0x0101,

    /*
     * Client has left server:
     *
     */
    NETMSG_PLAYER_QUIT  = 0x0102,

    /*
     * Client has moved
     *
     *  int32_t dx
     *  int32_t dy
     */
    NETMSG_CLIENT_MOVE  = 0x0201,
    
    /*
     * Initial player info
     *
     *  uint32_t x
     *  uint32_t y
     */
    NETMSG_PLAYER_INFO  = 0x0300,

    /*
     * Player position update
     *
     *  uint32_t x
     *  uint32_t y
     */
    NETMSG_PLAYER_POSITION  = 0x0301,
};

#endif