Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/PacketManager.h @ 458

Last change on this file since 458 was 440, checked in by scheusso, 17 years ago

added dummyserver3.cc (implements a chatserver, including main)

File size: 2.1 KB
RevLine 
[199]1#ifndef PACKETMANAGER_H_
2#define PACKETMANAGER_H_
3
[400]4#include <string>
[199]5#include <enet/enet.h>
[415]6#include "PacketTypes.h"
[199]7
[440]8#define CLIENTID_CLIENT -1
9
[223]10//enum netowk generaly used to set the type ID of a packet
[413]11namespace network{
12 
[415]13 
[199]14
[415]15
16
[223]17/*
18 * class to generate packets
19 *
[332]20 * @autor: Dumeni Manatschal
[223]21 *
22*/ 
[199]23class PacketGenerator
24{
25public:
26        PacketGenerator();
[223]27        //call one of this functions out of an instance of PacketGenerator to create a packet
[199]28        ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
29        ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
30        ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
[440]31  ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
32  ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
33  ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
[199]34private:
35};
36
[223]37/*
38 * class used to decode incoming packets
39 *
[332]40 * @autor: Dumeni Manatschal
[223]41 *
42*/
[199]43class PacketDecoder
44{
45public:
46        PacketDecoder();
[223]47        //call this function to decode, it calls the right decoding function below
[203]48        bool elaborate( ENetPacket* packet, int clientId );
[415]49       
[199]50private:
[400]51       
[401]52       
[199]53       
[440]54  void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
55  void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
56  void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
57  void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT);
58  void gstate( ENetPacket* packet );
59  void clid( ENetPacket *packet);
[199]60       
[369]61  //process data
[374]62  //two functions are note yet implemented!
63  //virtual void processGamestate(GameState *state);
[440]64  virtual void processChat( chat *data, int clientId);
[400]65  virtual void processClassid( classid *cid);
[374]66  //virtual void processAck( ack *data);
[369]67 
[199]68        //print functions
69        void printAck( ack* data );
70        void printMouse( mouse* data );
71        void printKey( keyboard* data );
[440]72        void printChat( chat* data, int clientId );
[413]73        void printGamestate( GameStateCompressed *data );
[440]74  void printClassid( classid *cid);
[199]75};
76}
77
78#endif /*PACKETMANAGER_H_*/
Note: See TracBrowser for help on using the repository browser.