Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 636 was 496, checked in by landauf, 16 years ago

added files from objecthierarchy, changed includes

File size: 2.1 KB
Line 
1//
2// C++ Interface: ConnectionManager
3//
4// Description:
5//
6//
7// Author:  Oliver Scheuss, (C) 2007
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#ifndef NETWORK_CONNECTIONMANAGER_H
13#define NETWORK_CONNECTIONMANAGER_H
14
15#include <iostream>
16#include <string>
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>
22// headerfiles
23#include "ClientInformation.h"
24#include "PacketBuffer.h"
25#include "PacketManager.h"
26#include "orxonox/core/CoreIncludes.h"
27
28namespace std{
29  bool operator<(ENetAddress a, ENetAddress b);
30}
31
32namespace network{
33  //
34#define NETWORK_PORT 55556
35#define NETWORK_MAX_CONNECTIONS 50
36#define NETWORK_WAIT_TIMEOUT 5000
37#define NETWORK_SEND_WAIT 5
38
39  struct ClientList{
40    ENetEvent *event;
41    int ID;
42    ClientList *next;
43  };
44 
45  class ConnectionManager{
46    public:
47    ConnectionManager(ClientInformation *head);
48    ConnectionManager(int port, const char *address, ClientInformation *head);
49    ConnectionManager(int port, std::string address, ClientInformation *head);
50    ENetPacket *getPacket(ENetAddress &address); // thread1
51    ENetPacket *getPacket(int &clientID);
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);
59    bool sendPackets();
60  private:
61    bool clientDisconnect(ENetPeer *peer);
62    //bool clientDisconnect(ENetPeer peer);
63    bool processData(ENetEvent *event);
64    bool addClient(ENetEvent *event);
65    void receiverThread();
66    void disconnectClients();
67    int getClientID(ENetPeer peer);
68    int getClientID(ENetAddress address);
69    void syncClassid(int clientID);
70    ENetPeer *getClientPeer(int clientID);
71    PacketBuffer buffer;
72    PacketGenerator packet_gen;
73   
74    ENetHost *server;
75    ENetAddress bindAddress;
76   
77    bool quit; // quit-variable (communication with threads)
78    ClientInformation *head_;
79  };
80
81
82
83
84
85
86
87
88}
89
90#endif
Note: See TracBrowser for help on using the repository browser.