Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/dummyserver.cc @ 442

Last change on this file since 442 was 442, checked in by scheusso, 17 years ago

still problems with chatserver/client

File size: 1.1 KB
RevLine 
[442]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#include "ClientInformation.h"
12
[367]13#ifdef WIN32
14#include <windows.h>
15#define usleep(x) Sleep((x)/1000)
16#else
17#include <unistd.h>
[442]18#endif
19
20
21using namespace network;
22
23int main(){
24  bool quit=false;
25  ENetPacket *packet;
26  ClientInformation clients;
27  ConnectionManager server = ConnectionManager(&clients);
28  server.createListener();
29
30  PacketDecoder dec;
31
32  while(!quit){
33    if(server.queueEmpty())
34// Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing!
35      usleep(10000000);
36    else{
37      ENetAddress addr;
38      packet=server.getPacket(addr);
39      if(packet==NULL){
40        // there was some error
41        //std::cout << "null pointer" << std::endl;
42        quit=true;
43      }
44      else{
45        //std::cout << "We received: " << packet->data << std::endl;
46        dec.elaborate(packet, 1);
47      }
48    }
49  }
50  server.quitListener();
51  return 0;
52}
Note: See TracBrowser for help on using the repository browser.