Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/PacketManager.h @ 885

Last change on this file since 885 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

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