Last change
on this file since 196 was
196,
checked in by scheusso, 16 years ago
|
created a dummyserver and dummyclient in order to test ConnectionManager and PacketBuffer with enet and boost_thread\n Makefile is used to build server and client
|
File size:
863 bytes
|
Rev | Line | |
---|
[173] | 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> |
---|
[188] | 18 | #include <enet/enet.h> |
---|
[174] | 19 | #include <boost/bind.hpp> |
---|
| 20 | #include <boost/thread/mutex.hpp> |
---|
[173] | 21 | |
---|
[174] | 22 | |
---|
[173] | 23 | namespace network{ |
---|
| 24 | |
---|
[196] | 25 | |
---|
[173] | 26 | struct PacketEnvelope{ |
---|
| 27 | int length; |
---|
| 28 | int data; |
---|
| 29 | }; |
---|
| 30 | |
---|
| 31 | struct QueueItem{ |
---|
[188] | 32 | ENetPacket *packet; |
---|
[173] | 33 | QueueItem *next; |
---|
| 34 | }; |
---|
| 35 | |
---|
| 36 | class PacketBuffer{ |
---|
| 37 | public: |
---|
| 38 | PacketBuffer(); |
---|
| 39 | bool isEmpty(); |
---|
[174] | 40 | bool isClosed(); |
---|
| 41 | void setClosed(bool value); |
---|
| 42 | void print(); |
---|
[173] | 43 | // pops a packet from the queue |
---|
[188] | 44 | ENetPacket *pop(); |
---|
[173] | 45 | // pushs a packet to the queue |
---|
[188] | 46 | bool push(ENetPacket *pck); |
---|
[196] | 47 | |
---|
[173] | 48 | private: |
---|
| 49 | QueueItem *first; |
---|
| 50 | QueueItem *last; |
---|
[174] | 51 | bool closed; |
---|
| 52 | |
---|
[173] | 53 | }; |
---|
| 54 | |
---|
| 55 | } //namespace |
---|
| 56 | #endif /* NETWORK_PACKETBUFFER_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.