Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/input/src/network/PacketManager.h @ 1076

Last change on this file since 1076 was 913, checked in by scheusso, 17 years ago

another dead bug

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