source:
code/branches/FICN/src/network/dummyserver3.cc
@
706
Last change on this file since 706 was 533, checked in by rgrieder, 17 years ago | |
---|---|
File size: 878 bytes |
Rev | Line | |
---|---|---|
[440] | 1 | #include <iostream> |
[475] | 2 | #include "PacketManager.h" |
3 | //#include "PacketTypes.h" | |
[440] | 4 | #include "Server.h" |
5 | ||
[533] | 6 | #ifdef WIN32 |
7 | #include <windows.h> | |
8 | #define usleep(x) Sleep((x)/1000) | |
9 | #else | |
10 | #include <unistd.h> | |
11 | #endif | |
12 | ||
[440] | 13 | namespace network{ |
14 | ||
[477] | 15 | class dummyserver3 : public Server{ |
[440] | 16 | public: |
17 | dummyserver3(); | |
18 | ~dummyserver3(); | |
19 | void loop(); | |
20 | private: | |
21 | void tick(); | |
[477] | 22 | void processChat( chat *data, int clientId); |
[440] | 23 | |
24 | ||
25 | ||
26 | }; | |
27 | ||
28 | dummyserver3::dummyserver3(){ | |
29 | } | |
30 | dummyserver3::~dummyserver3(){ | |
31 | } | |
32 | ||
33 | void dummyserver3::loop(){ | |
34 | open(); | |
[444] | 35 | while(true){ |
[440] | 36 | tick(); |
[475] | 37 | usleep(100); |
[444] | 38 | } |
[440] | 39 | } |
40 | ||
41 | void dummyserver3::processChat( chat *data, int clientId){ | |
42 | std::cout << "Client " << clientId << " sent: " << data->message << std::endl; | |
43 | sendMSG(data->message); | |
44 | } | |
45 | ||
46 | void dummyserver3::tick(){ | |
[446] | 47 | processQueue(); |
[440] | 48 | } |
49 | ||
[441] | 50 | |
[440] | 51 | } |
52 | ||
[441] | 53 | int main(int argc, char **argv[]){ |
54 | network::dummyserver3 server; | |
55 | server.loop(); | |
56 | return 0; | |
[440] | 57 | } |
Note: See TracBrowser
for help on using the repository browser.