Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 673 was 673, checked in by rgrieder, 16 years ago
  • deleted obsolete classes: BaseEntity, Entity, Light and SceneNode (please complain if not agreed)
  • improved include guard naming consistency
File size: 2.3 KB
Line 
1#ifndef _PacketManager_H__
2#define _PacketManager_H__
3
4#include <string>
5#include <enet/enet.h>
6#include "PacketTypes.h"
7
8#define CLIENTID_CLIENT -1
9
10//enum netowk generaly used to set the type ID of a packet
11namespace network{
12 
13 
14
15
16
17/*
18 * class to generate packets
19 *
20 * @autor: Dumeni Manatschal
21 *
22*/ 
23class PacketGenerator
24{
25public:
26        PacketGenerator();
27        //call one of this functions out of an instance of PacketGenerator to create a packet
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 );
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 );
34private:
35};
36
37/*
38 * class used to decode incoming packets
39 *
40 * @autor: Dumeni Manatschal
41 *
42*/
43class PacketDecoder
44{
45public:
46        PacketDecoder();
47  virtual ~PacketDecoder();
48        //call this function to decode, it calls the right decoding function below
49        bool elaborate( ENetPacket* packet, int clientId );
50protected:
51   
52  virtual void processChat( chat *data, int clientId);
53       
54       
55private:
56       
57       
58       
59  void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
60  void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
61  void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
62  void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT);
63  void gstate( ENetPacket* packet );
64  void clid( ENetPacket *packet);
65       
66  //process data
67  //two functions are note yet implemented!
68  virtual void processGamestate(GameStateCompressed *state);
69  virtual void processAck( ack *data, int clientID);
70  void processClassid( classid *cid);
71  //virtual void processAck( ack *data);
72 
73        //print functions
74        void printAck( ack* data );
75        void printMouse( mouse* data );
76        void printKey( keyboard* data );
77        void printChat( chat* data, int clientId );
78        void printGamestate( GameStateCompressed *data );
79  void printClassid( classid *cid);
80};
81}
82
83#endif /* _PacketManager_H__ */
Note: See TracBrowser for help on using the repository browser.