Changeset 380 for code/branches/FICN/src/network/ConnectionManager.h
- Timestamp:
- Dec 4, 2007, 8:22:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/ConnectionManager.h
r369 r380 15 15 #include <iostream> 16 16 #include <string> 17 #include <map> 18 #include <vector> 17 19 // enet library for networking support 18 20 #include <enet/enet.h> … … 20 22 #include <boost/thread/thread.hpp> 21 23 #include <boost/bind.hpp> 22 // headerfile 24 // headerfiles 23 25 #include "ConnectionManager.h" 24 26 #include "PacketBuffer.h" … … 30 32 #define NETWORK_WAIT_TIMEOUT 5000 31 33 #define NETWORK_SEND_WAIT 5 32 //just some defines to make life easier ;)33 // #define ENetEvent std::ENetEvent34 // #define ENetHost std::ENetHost35 // #define ENetAddress std::ENetAddress36 // #define ENetPeer std::ENetPeer37 34 38 35 struct ClientList{ … … 48 45 ConnectionManager(int port, std::string address); 49 46 ENetPacket *getPacket(ENetAddress &address); // thread1 50 // check wheter the packet queue is empty47 ENetPacket *getPacket(int &clientID); 51 48 bool queueEmpty(); 52 // create a new listener thread53 49 void createListener(); 54 50 bool quitListener(); 55 // add a packet to queue for a specific client peer56 51 bool addPacket(ENetPacket *packet, ENetPeer *peer); 57 // add ad packet to queue for a specific client ID58 52 bool addPacket(ENetPacket *packet, int ID); 59 // add a packet to queue for all clients60 53 bool addPacketAll(ENetPacket *packet); 61 // send out all queued packets62 54 bool sendPackets(ENetEvent *event); 63 55 bool sendPackets(); 64 56 private: 65 57 bool clientDisconnect(ENetPeer *peer); 58 bool clientDisconnect(ENetPeer peer); 66 59 bool processData(ENetEvent *event); 67 60 bool addClient(ENetEvent *event); 68 // implementation of the listener 69 void receiverThread(); //thread2 61 void receiverThread(); 70 62 void disconnectClients(); 71 //packetbuffer 63 int getClientID(ENetPeer peer); 64 int getClientID(ENetAddress address); 65 ENetPeer getClientPeer(int clientID); 72 66 PacketBuffer buffer; 73 // enet stuff67 74 68 ENetHost *server; 75 69 ENetAddress bindAddress; 76 // quit-variable (communication with threads) 77 bool quit; 78 // clientlist 79 ClientList *client; 80 // thread group 81 // boost::thread_group threads; 70 71 bool quit; // quit-variable (communication with threads) 72 std::map<ENetAddress, int> clientMap; 73 std::map<ENetAddress, ENetPeer> peerMap; 74 std::vector<ENetAddress> clientVector; 82 75 }; 83 76
Note: See TracChangeset
for help on using the changeset viewer.