Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/ConnectionManager.h @ 1061

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

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

File size: 3.2 KB
RevLine 
[1056]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
[173]29//
30// C++ Interface: ConnectionManager
31//
[285]32// Description:
[173]33//
34//
[196]35// Author:  Oliver Scheuss, (C) 2007
[173]36//
37// Copyright: See COPYING file that comes with this distribution
38//
39//
[673]40#ifndef _ConnectionManager_H__
41#define _ConnectionManager_H__
[173]42
[230]43#include <string>
[1021]44#include <map>
[196]45// enet library for networking support
46#include <enet/enet.h>
[777]47
48#include "NetworkPrereqs.h"
[285]49#include "PacketBuffer.h"
[400]50#include "PacketManager.h"
[173]51
[777]52namespace std
53{
[381]54  bool operator<(ENetAddress a, ENetAddress b);
55}
56
[777]57namespace network
58{
[211]59#define NETWORK_PORT 55556
[173]60#define NETWORK_MAX_CONNECTIONS 50
61#define NETWORK_WAIT_TIMEOUT 5000
[196]62#define NETWORK_SEND_WAIT 5
[285]63
[173]64  struct ClientList{
[196]65    ENetEvent *event;
[173]66    int ID;
67    ClientList *next;
68  };
[777]69
[173]70  class ConnectionManager{
[777]71  public:
[436]72    ConnectionManager(ClientInformation *head);
73    ConnectionManager(int port, const char *address, ClientInformation *head);
74    ConnectionManager(int port, std::string address, ClientInformation *head);
[204]75    ENetPacket *getPacket(ENetAddress &address); // thread1
[380]76    ENetPacket *getPacket(int &clientID);
[196]77    bool queueEmpty();
78    void createListener();
79    bool quitListener();
80    bool addPacket(ENetPacket *packet, ENetPeer *peer);
81    bool addPacket(ENetPacket *packet, int ID);
82    bool addPacketAll(ENetPacket *packet);
83    bool sendPackets(ENetEvent *event);
[369]84    bool sendPackets();
[436]85  private:
[196]86    bool clientDisconnect(ENetPeer *peer);
[436]87    //bool clientDisconnect(ENetPeer peer);
[196]88    bool processData(ENetEvent *event);
89    bool addClient(ENetEvent *event);
[380]90    void receiverThread();
[369]91    void disconnectClients();
[380]92    int getClientID(ENetPeer peer);
93    int getClientID(ENetAddress address);
[400]94    void syncClassid(int clientID);
[436]95    ENetPeer *getClientPeer(int clientID);
[173]96    PacketBuffer buffer;
[400]97    PacketGenerator packet_gen;
[777]98
[173]99    ENetHost *server;
100    ENetAddress bindAddress;
[777]101
[380]102    bool quit; // quit-variable (communication with threads)
[436]103    ClientInformation *head_;
[1056]104
[1021]105    //functions to map what object every clients uses
106    std::map<int, int> clientsShip;
107    void addClientsObjectID( int clientID, int objectID );
108    int getClientsShipID( int clientID );
109    int getObjectsClientID( int objectID );
110    void deleteClientIDReg( int clientID );
111    void deleteObjectIDReg( int objectID );
[173]112  };
[285]113
114
115
116
117
118
119
120
[173]121}
122
[673]123#endif /* _ConnectionManager_H__ */
Note: See TracBrowser for help on using the repository browser.