- Timestamp:
- Dec 17, 2010, 10:41:24 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network5/src/libraries/network/Connection.h
r7163 r7772 43 43 #include "NetworkPrereqs.h" 44 44 45 #include <deque> 46 47 namespace boost 48 { 49 class thread; 50 class mutex; 51 } 52 45 53 namespace orxonox 46 54 { 47 const unsigned int NETWORK_PORT = 55556; 48 const unsigned int NETWORK_MAX_CONNECTIONS = 50; 49 const unsigned int NETWORK_WAIT_TIMEOUT = 0; 50 const unsigned int NETWORK_DEFAULT_CHANNEL = 0; 51 const unsigned int NETWORK_MAX_QUEUE_PROCESS_TIME = 5; 52 53 class _NetworkExport Connection{ 55 const unsigned int NETWORK_PORT = 55556; 56 const unsigned int NETWORK_MAX_CONNECTIONS = 50; 57 const unsigned int NETWORK_WAIT_TIMEOUT = 1; 58 const unsigned int NETWORK_MAX_QUEUE_PROCESS_TIME = 5; 59 60 namespace outgoingEventType 61 { 62 enum Value 63 { 64 sendPacket = 1, 65 disconnectPeer = 2, 66 broadcastPacket = 3 67 }; 68 69 } 70 71 struct _NetworkExport outgoingEvent 72 { 73 ENetPeer* peer; 74 outgoingEventType::Value type; 75 ENetPacket* packet; 76 ENetChannelID channelID; 77 }; 78 79 class _NetworkExport Connection 80 { 54 81 public: 55 82 virtual ~Connection(); 56 83 57 static bool addPacket(ENetPacket *packet, ENetPeer *peer);58 bool sendPackets();84 void addPacket(ENetPacket *packet, ENetPeer *peer, uint8_t channelID); 85 void broadcastPacket(ENetPacket* packet, uint8_t channelID); 59 86 ENetHost* getHost(){ return this->host_; } 60 87 … … 63 90 // static Connection* getInstance(){ return Connection::instance_; } 64 91 65 int service(ENetEvent* event); 92 // int service(ENetEvent* event); 93 void startCommunicationThread(); 94 void stopCommunicationThread(); 95 void communicationThread(); 66 96 virtual void disconnectPeer(ENetPeer *peer); 67 97 … … 71 101 virtual bool processPacket(ENetEvent* event); 72 102 73 ENetHost *host_; 103 ENetHost* host_; 104 boost::mutex* incomingEventsMutex_; 105 boost::mutex* outgoingEventsMutex_; 74 106 private: 75 ENetAddress *bindAddress_; 107 boost::thread* communicationThread_; 108 bool bCommunicationThreadRunning_; 109 ENetAddress* bindAddress_; 110 std::deque<ENetEvent> incomingEvents_; 111 std::deque<outgoingEvent> outgoingEvents_; 76 112 77 113 // static Connection *instance_;
Note: See TracChangeset
for help on using the changeset viewer.