Last change
on this file since 351 was
346,
checked in by rgrieder, 17 years ago
|
- adjusted the entire source to compile under windows visual studio too:
- added some ugly conversions
- changed some illegal code pieces (gcc however accepted it)
- added a few files from reto's framework to evade linker errors (no more dynamic linking)
- inserted some 'return true' to justify the return type
- excluded the levelLoader in the orxonox.cc (couldn't make it work, parsing error)
- wrote about 5 code #branches to compensate for missing usleep() under windows
|
File size:
1.1 KB
|
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 | // workaround for usleep(int) under windows |
---|
13 | #ifdef WIN32 |
---|
14 | #include "winbase.h" |
---|
15 | #endif |
---|
16 | |
---|
17 | |
---|
18 | using namespace network; |
---|
19 | |
---|
20 | int main(){ |
---|
21 | ConnectionManager server = ConnectionManager(); |
---|
22 | bool quit=false; |
---|
23 | ENetPacket *packet; |
---|
24 | ENetEvent event; |
---|
25 | server.createListener(); |
---|
26 | |
---|
27 | PacketDecoder dec; |
---|
28 | |
---|
29 | while(!quit){ |
---|
30 | if(server.queueEmpty()) |
---|
31 | // under windows, use Sleep(milliseconds) instead of usleep(microseconds) |
---|
32 | // Warning: Sleep(1) is ten times longer than usleep(100)! |
---|
33 | #ifdef WIN32 |
---|
34 | Sleep(1); |
---|
35 | #else |
---|
36 | usleep(100); |
---|
37 | #endif |
---|
38 | else{ |
---|
39 | ENetAddress addr; |
---|
40 | packet=server.getPacket(addr); |
---|
41 | if(packet==NULL){ |
---|
42 | // there was some error |
---|
43 | //std::cout << "null pointer" << std::endl; |
---|
44 | quit=true; |
---|
45 | } |
---|
46 | else{ |
---|
47 | //std::cout << "We received: " << packet->data << std::endl; |
---|
48 | dec.elaborate(packet, 1); |
---|
49 | } |
---|
50 | } |
---|
51 | } |
---|
52 | server.quitListener(); |
---|
53 | return 0; |
---|
54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.