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