Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 417 was 415, checked in by scheusso, 17 years ago

errorless

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