Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cmake/src/network/PacketManager.h @ 1229

Last change on this file since 1229 was 1062, checked in by rgrieder, 17 years ago
  • changed header file inclusion order
File size: 3.3 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Dumeni Manatschal, (C) 2007
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _PacketManager_H__
30#define _PacketManager_H__
31
32#include "NetworkPrereqs.h"
33
34#include <string>
35#include <enet/enet.h>
36
37#include "core/CoreIncludes.h"
38
39#define CLIENTID_CLIENT -1
40
41//enum netowk generally used to set the type ID of a packet
42namespace network
43{
44  /*
45  * class to generate packets
46  *
47  * @autor: Dumeni Manatschal
48  *
49  */
50  class PacketGenerator
51  {
52  public:
53    PacketGenerator();
54    //call one of this functions out of an instance of PacketGenerator to create a packet
55    ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
56    ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
57    ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
58    ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
59    ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
60    ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
61  private:
62  };
63
64  /*
65  * class used to decode incoming packets
66  *
67  * @autor: Dumeni Manatschal
68  *
69  */
70  class _NetworkExport PacketDecoder
71  {
72  public:
73    PacketDecoder();
74    virtual ~PacketDecoder();
75    //call this function to decode, it calls the right decoding function below
76    bool elaborate( ENetPacket* packet, int clientId );
77  protected:
78
79    virtual void processChat( chat *data, int clientId);
80
81
82  private:
83
84
85
86    void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
87    void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
88    void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
89    void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT);
90    void gstate( ENetPacket* packet );
91    void clid( ENetPacket *packet);
92
93    //process data
94    //two functions are note yet implemented!
95    virtual void processGamestate(GameStateCompressed *state);
96    virtual void processAck( ack *data, int clientID);
97    virtual void processClassid( classid *cid);
98    //virtual void processAck( ack *data);
99
100    //print functions
101    void printAck( ack* data );
102    void printMouse( mouse* data );
103    void printKey( keyboard* data );
104    void printChat( chat* data, int clientId );
105    void printGamestate( GameStateCompressed *data );
106    void printClassid( classid *cid);
107  };
108}
109
110#endif /* _PacketManager_H__ */
Note: See TracBrowser for help on using the repository browser.