Last change
on this file since 423 was
367,
checked in by rgrieder, 17 years ago
|
- made certain files windows compatible
- solved conflict with unresolved external symbol registerAllVariables() by commenting call
|
File size:
1004 bytes
|
Line | |
---|
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> |
---|
9 | #include "ConnectionManager.h" |
---|
10 | #include "PacketManager.h" |
---|
11 | |
---|
12 | #ifdef WIN32 |
---|
13 | #include <windows.h> |
---|
14 | #define usleep(x) Sleep((x)/1000) |
---|
15 | #else |
---|
16 | #include <unistd.h> |
---|
17 | #endif |
---|
18 | |
---|
19 | |
---|
20 | using namespace network; |
---|
21 | |
---|
22 | int main(){ |
---|
23 | ConnectionManager server = ConnectionManager(); |
---|
24 | bool quit=false; |
---|
25 | ENetPacket *packet; |
---|
26 | server.createListener(); |
---|
27 | |
---|
28 | PacketDecoder dec; |
---|
29 | |
---|
30 | while(!quit){ |
---|
31 | if(server.queueEmpty()) |
---|
32 | // Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing! |
---|
33 | usleep(100); |
---|
34 | else{ |
---|
35 | ENetAddress addr; |
---|
36 | packet=server.getPacket(addr); |
---|
37 | if(packet==NULL){ |
---|
38 | // there was some error |
---|
39 | //std::cout << "null pointer" << std::endl; |
---|
40 | quit=true; |
---|
41 | } |
---|
42 | else{ |
---|
43 | //std::cout << "We received: " << packet->data << std::endl; |
---|
44 | dec.elaborate(packet, 1); |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | server.quitListener(); |
---|
49 | return 0; |
---|
50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.