Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 777 was 777, checked in by rgrieder, 17 years ago
  • added dll support to the network library
  • improved header file dependency in network
File size: 1.9 KB
Line 
1/*
2*   ORXONOX - the hottest 3D action shooter ever to exist
3*
4*
5*   License notice:
6*
7*   This program is free software; you can redistribute it and/or
8*   modify it under the terms of the GNU General Public License
9*   as published by the Free Software Foundation; either version 2
10*   of the License, or (at your option) any later version.
11*
12*   This program is distributed in the hope that it will be useful,
13*   but WITHOUT ANY WARRANTY; without even the implied warranty of
14*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*   GNU General Public License for more details.
16*
17*   You should have received a copy of the GNU General Public License
18*   along with this program; if not, write to the Free Software
19*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20*
21*   Author:
22*      Oliver Scheuss, (C) 2007
23*   Co-authors:
24*      ...
25*
26*/
27
28//
29// Dummy server to test ConnectionManager and PacketBuffer classes
30//
31// Author: Oliver Scheuss
32
33#include <iostream>
34#include <enet/enet.h>
35
36#include "util/Sleep.h"
37#include "ConnectionManager.h"
38#include "PacketManager.h"
39#include "ClientInformation.h"
40
41using namespace network;
42
43int main(){
44  bool quit=false;
45  ENetPacket *packet;
46  ClientInformation clients;
47  ConnectionManager server = ConnectionManager(&clients);
48  server.createListener();
49
50  PacketDecoder dec;
51
52  while(!quit){
53    if(server.queueEmpty())
54      // Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing!
55      usleep(1);
56    else{
57      ENetAddress addr;
58      packet=server.getPacket(addr);
59      if(packet==NULL){
60        // there was some error
61        //std::cout << "null pointer" << std::endl;
62        quit=true;
63      }
64      else{
65        //std::cout << "We received: " << packet->data << std::endl;
66        dec.elaborate(packet, 1);
67      }
68    }
69  }
70  server.quitListener();
71  return 0;
72}
Note: See TracBrowser for help on using the repository browser.