Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/ConnectionManager.h @ 744

Last change on this file since 744 was 673, checked in by rgrieder, 17 years ago
  • deleted obsolete classes: BaseEntity, Entity, Light and SceneNode (please complain if not agreed)
  • improved include guard naming consistency
File size: 2.1 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
[196]15#include <iostream>
[230]16#include <string>
[196]17// enet library for networking support
18#include <enet/enet.h>
19// boost.thread library for multithreading support
20#include <boost/thread/thread.hpp>
21#include <boost/bind.hpp>
[380]22// headerfiles
[436]23#include "ClientInformation.h"
[285]24#include "PacketBuffer.h"
[400]25#include "PacketManager.h"
[496]26#include "orxonox/core/CoreIncludes.h"
[173]27
[381]28namespace std{
29  bool operator<(ENetAddress a, ENetAddress b);
30}
31
[173]32namespace network{
33  //
[211]34#define NETWORK_PORT 55556
[173]35#define NETWORK_MAX_CONNECTIONS 50
36#define NETWORK_WAIT_TIMEOUT 5000
[196]37#define NETWORK_SEND_WAIT 5
[285]38
[173]39  struct ClientList{
[196]40    ENetEvent *event;
[173]41    int ID;
42    ClientList *next;
43  };
[381]44 
[173]45  class ConnectionManager{
46    public:
[436]47    ConnectionManager(ClientInformation *head);
48    ConnectionManager(int port, const char *address, ClientInformation *head);
49    ConnectionManager(int port, std::string address, ClientInformation *head);
[204]50    ENetPacket *getPacket(ENetAddress &address); // thread1
[380]51    ENetPacket *getPacket(int &clientID);
[196]52    bool queueEmpty();
53    void createListener();
54    bool quitListener();
55    bool addPacket(ENetPacket *packet, ENetPeer *peer);
56    bool addPacket(ENetPacket *packet, int ID);
57    bool addPacketAll(ENetPacket *packet);
58    bool sendPackets(ENetEvent *event);
[369]59    bool sendPackets();
[436]60  private:
[196]61    bool clientDisconnect(ENetPeer *peer);
[436]62    //bool clientDisconnect(ENetPeer peer);
[196]63    bool processData(ENetEvent *event);
64    bool addClient(ENetEvent *event);
[380]65    void receiverThread();
[369]66    void disconnectClients();
[380]67    int getClientID(ENetPeer peer);
68    int getClientID(ENetAddress address);
[400]69    void syncClassid(int clientID);
[436]70    ENetPeer *getClientPeer(int clientID);
[173]71    PacketBuffer buffer;
[400]72    PacketGenerator packet_gen;
[380]73   
[173]74    ENetHost *server;
75    ENetAddress bindAddress;
[380]76   
77    bool quit; // quit-variable (communication with threads)
[436]78    ClientInformation *head_;
[173]79  };
[285]80
81
82
83
84
85
86
87
[173]88}
89
[673]90#endif /* _ConnectionManager_H__ */
Note: See TracBrowser for help on using the repository browser.