Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/PacketBuffer.h @ 188

Last change on this file since 188 was 188, checked in by scheusso, 16 years ago

adapted PacketBuffer to work with ENetPacket *

File size: 1.0 KB
Line 
1//
2// C++ Interface: PacketBuffer
3//
4// Description:
5//
6//
7// Author:  Oliver Scheuss, (C) 2007
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12
13#ifndef NETWORK_PACKETBUFFER_H
14#define NETWORK_PACKETBUFFER_H
15
16#include <queue>
17#include <string>
18#include <enet/enet.h>
19#include <boost/bind.hpp>
20#include <boost/thread/mutex.hpp>
21#include <boost/thread/mutex.hpp>
22
23//this is needed in order to make the packetbuffer threadsafe
24boost::mutex networkPacketBufferMutex;
25
26namespace network{
27
28struct PacketEnvelope{
29  int length;
30  int data;
31};
32
33struct QueueItem{
34  ENetPacket *packet;
35  QueueItem *next;
36};
37
38class PacketBuffer{
39public:
40  PacketBuffer();
41  bool isEmpty();
42  bool isClosed();
43  void setClosed(bool value);
44  void print();
45  // pops a packet from the queue
46  ENetPacket *pop();
47  // pushs a packet to the queue
48  bool push(ENetPacket *pck);
49private:
50  QueueItem *first;
51  QueueItem *last;
52  bool closed;
53 
54  //make it threadsafe
55//   boost::mutex mutex;
56};
57
58} //namespace
59#endif /* NETWORK_PACKETBUFFER_H */
Note: See TracBrowser for help on using the repository browser.