Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/src/network/dummyserver.cc @ 1835

Last change on this file since 1835 was 859, checked in by landauf, 17 years ago

more or less a copy of the trunk

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 "PacketTypes.h"
40#include "ClientInformation.h"
41
42using namespace network;
43
44int main(){
45  bool quit=false;
46  ENetPacket *packet;
47  ClientInformation clients;
48  ConnectionManager server = ConnectionManager(&clients);
49  server.createListener();
50
51  PacketDecoder dec;
52
53  while(!quit){
54    if(server.queueEmpty())
55      // Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing!
56      usleep(1);
57    else{
58      ENetAddress addr;
59      packet=server.getPacket(addr);
60      if(packet==NULL){
61        // there was some error
62        //std::cout << "null pointer" << std::endl;
63        quit=true;
64      }
65      else{
66        //std::cout << "We received: " << packet->data << std::endl;
67        dec.elaborate(packet, 1);
68      }
69    }
70  }
71  server.quitListener();
72  return 0;
73}
Note: See TracBrowser for help on using the repository browser.