Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/lod/src/network/packet/Packet.h @ 1835

Last change on this file since 1835 was 1763, checked in by rgrieder, 16 years ago

added svn:eol-style native to all the files that were missing it

  • Property svn:eol-style set to native
File size: 2.2 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 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
24 *   Co-authors:
25 *      ...
26 *
27 */
28#ifndef NETWORKPACKET_H
29#define NETWORKPACKET_H
30
31#include <map>
32#include <enet/enet.h>
33
34namespace network {
35
36namespace packet{
37 
38namespace ENUM{
39  enum Direction{
40    Incoming,
41    Outgoing,
42    Bidirectional
43  };
44  enum Type{
45    Acknowledgement,
46    Gamestate,
47    ClassID,
48    Chat,
49    Welcome
50  };
51}
52 
53/**
54        @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
55*/
56class Packet{
57  public:
58    Packet(const Packet &p);
59    virtual ~Packet();
60    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
61    static void deletePacket(ENetPacket *packet);
62   
63    virtual unsigned char *getData(){ return data_; };
64    virtual unsigned int getSize() const =0;
65    virtual bool process()=0;
66    enet_uint32 getFlags()
67      { return flags_; }
68    int getClientID()
69      { return clientID_; }
70    void setClientID( int id )
71      { clientID_ = id; }
72   
73    bool send();
74  protected:
75    Packet();
76    Packet(unsigned char *data, int clientID);
77//    Packet(ENetPacket *packet, ENetPeer *peer);
78    enet_uint32 flags_;
79    int clientID_;
80    ENUM::Direction packetDirection_;
81    unsigned char *data_;
82  private:
83    static std::map<ENetPacket *, Packet *> packetMap_;
84    ENetPacket *enetPacket_;
85};
86
87} //namespace packet
88
89} //namespace network
90
91#endif
Note: See TracBrowser for help on using the repository browser.