Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 947 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

File size: 1.9 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>
[196]16// enet library for networking support
17#include <enet/enet.h>
[777]18
19#include "NetworkPrereqs.h"
[285]20#include "PacketBuffer.h"
[400]21#include "PacketManager.h"
[173]22
[777]23namespace std
24{
[381]25  bool operator<(ENetAddress a, ENetAddress b);
26}
27
[777]28namespace network
29{
[211]30#define NETWORK_PORT 55556
[173]31#define NETWORK_MAX_CONNECTIONS 50
32#define NETWORK_WAIT_TIMEOUT 5000
[196]33#define NETWORK_SEND_WAIT 5
[285]34
[173]35  struct ClientList{
[196]36    ENetEvent *event;
[173]37    int ID;
38    ClientList *next;
39  };
[777]40
[173]41  class ConnectionManager{
[777]42  public:
[436]43    ConnectionManager(ClientInformation *head);
44    ConnectionManager(int port, const char *address, ClientInformation *head);
45    ConnectionManager(int port, std::string address, ClientInformation *head);
[204]46    ENetPacket *getPacket(ENetAddress &address); // thread1
[380]47    ENetPacket *getPacket(int &clientID);
[196]48    bool queueEmpty();
49    void createListener();
50    bool quitListener();
51    bool addPacket(ENetPacket *packet, ENetPeer *peer);
52    bool addPacket(ENetPacket *packet, int ID);
53    bool addPacketAll(ENetPacket *packet);
54    bool sendPackets(ENetEvent *event);
[369]55    bool sendPackets();
[436]56  private:
[196]57    bool clientDisconnect(ENetPeer *peer);
[436]58    //bool clientDisconnect(ENetPeer peer);
[196]59    bool processData(ENetEvent *event);
60    bool addClient(ENetEvent *event);
[380]61    void receiverThread();
[369]62    void disconnectClients();
[380]63    int getClientID(ENetPeer peer);
64    int getClientID(ENetAddress address);
[400]65    void syncClassid(int clientID);
[436]66    ENetPeer *getClientPeer(int clientID);
[173]67    PacketBuffer buffer;
[400]68    PacketGenerator packet_gen;
[777]69
[173]70    ENetHost *server;
71    ENetAddress bindAddress;
[777]72
[380]73    bool quit; // quit-variable (communication with threads)
[436]74    ClientInformation *head_;
[173]75  };
[285]76
77
78
79
80
81
82
83
[173]84}
85
[673]86#endif /* _ConnectionManager_H__ */
Note: See TracBrowser for help on using the repository browser.