Last change
on this file since 311 was
285,
checked in by nicolasc, 17 years ago
|
cleaned up network, builds with CML
|
File size:
842 bytes
|
Rev | Line | |
---|
[196] | 1 | // |
---|
| 2 | // Dummy server to test ConnectionManager and PacketBuffer classes |
---|
| 3 | // |
---|
| 4 | // Author: Oliver Scheuss |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | #include <iostream> |
---|
| 8 | #include "enet/enet.h" |
---|
[285] | 9 | #include "ConnectionManager.h" |
---|
| 10 | #include "PacketManager.h" |
---|
[196] | 11 | |
---|
| 12 | using namespace network; |
---|
| 13 | |
---|
| 14 | int main(){ |
---|
| 15 | ConnectionManager server = ConnectionManager(); |
---|
| 16 | bool quit=false; |
---|
| 17 | ENetPacket *packet; |
---|
[204] | 18 | ENetEvent event; |
---|
[196] | 19 | server.createListener(); |
---|
[285] | 20 | |
---|
[204] | 21 | PacketDecoder dec; |
---|
[285] | 22 | |
---|
[196] | 23 | while(!quit){ |
---|
| 24 | if(server.queueEmpty()) |
---|
| 25 | usleep(100); |
---|
| 26 | else{ |
---|
[204] | 27 | ENetAddress addr; |
---|
| 28 | packet=server.getPacket(addr); |
---|
[196] | 29 | if(packet==NULL){ |
---|
| 30 | // there was some error |
---|
| 31 | //std::cout << "null pointer" << std::endl; |
---|
| 32 | quit=true; |
---|
| 33 | } |
---|
[204] | 34 | else{ |
---|
| 35 | //std::cout << "We received: " << packet->data << std::endl; |
---|
| 36 | dec.elaborate(packet, 1); |
---|
| 37 | } |
---|
[196] | 38 | } |
---|
| 39 | } |
---|
| 40 | server.quitListener(); |
---|
| 41 | return 0; |
---|
| 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.