Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/ConnectionManager.h @ 888

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

sdfsdf

File size: 2.3 KB
RevLine 
[173]1//
2// C++ Interface: ConnectionManager
3//
[285]4// Description:
[173]5//
6//
[196]7// Author:  Oliver Scheuss, (C) 2007
[173]8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
[673]12#ifndef _ConnectionManager_H__
13#define _ConnectionManager_H__
[173]14
[230]15#include <string>
[888]16#include <map>
[196]17// enet library for networking support
18#include <enet/enet.h>
[777]19
20#include "NetworkPrereqs.h"
[285]21#include "PacketBuffer.h"
[400]22#include "PacketManager.h"
[173]23
[777]24namespace std
25{
[381]26  bool operator<(ENetAddress a, ENetAddress b);
27}
28
[777]29namespace network
30{
[211]31#define NETWORK_PORT 55556
[173]32#define NETWORK_MAX_CONNECTIONS 50
33#define NETWORK_WAIT_TIMEOUT 5000
[196]34#define NETWORK_SEND_WAIT 5
[285]35
[173]36  struct ClientList{
[196]37    ENetEvent *event;
[173]38    int ID;
39    ClientList *next;
40  };
[777]41
[173]42  class ConnectionManager{
[777]43  public:
[436]44    ConnectionManager(ClientInformation *head);
45    ConnectionManager(int port, const char *address, ClientInformation *head);
46    ConnectionManager(int port, std::string address, ClientInformation *head);
[204]47    ENetPacket *getPacket(ENetAddress &address); // thread1
[380]48    ENetPacket *getPacket(int &clientID);
[196]49    bool queueEmpty();
50    void createListener();
51    bool quitListener();
52    bool addPacket(ENetPacket *packet, ENetPeer *peer);
53    bool addPacket(ENetPacket *packet, int ID);
54    bool addPacketAll(ENetPacket *packet);
55    bool sendPackets(ENetEvent *event);
[369]56    bool sendPackets();
[436]57  private:
[196]58    bool clientDisconnect(ENetPeer *peer);
[436]59    //bool clientDisconnect(ENetPeer peer);
[196]60    bool processData(ENetEvent *event);
61    bool addClient(ENetEvent *event);
[380]62    void receiverThread();
[369]63    void disconnectClients();
[380]64    int getClientID(ENetPeer peer);
65    int getClientID(ENetAddress address);
[400]66    void syncClassid(int clientID);
[436]67    ENetPeer *getClientPeer(int clientID);
[173]68    PacketBuffer buffer;
[400]69    PacketGenerator packet_gen;
[777]70
[173]71    ENetHost *server;
72    ENetAddress bindAddress;
[777]73
[380]74    bool quit; // quit-variable (communication with threads)
[436]75    ClientInformation *head_;
[888]76   
77    //functions to map what object every clients uses
78    std::map<int, int> clientsShip;
79    void addClientsObjectID( int clientID, int objectID );
80    int getClientsShipID( int clientID );
81    int getObjectsClientID( int objectID );
82    void deleteClientIDReg( int clientID );
83    void deleteObjectIDReg( int objectID );
[173]84  };
[285]85
86
87
88
89
90
91
92
[173]93}
94
[673]95#endif /* _ConnectionManager_H__ */
Note: See TracBrowser for help on using the repository browser.