Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/input/src/network/dummyserver.cc @ 1213

Last change on this file since 1213 was 1056, checked in by landauf, 17 years ago

don't panic, no codechanges!
added a link to www.orxonox.net

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