Changeset 3447
- Timestamp:
- 02/25/10 17:20:28 (5 months ago)
- Location:
- plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking
- Files:
-
- 31 modified
-
UDP/I_Message.hpp (modified) (1 diff)
-
src/Endpoint.cpp (modified) (3 diffs)
-
src/Endpoint.hpp (modified) (2 diffs)
-
src/HTTP/Message.cpp (modified) (1 diff)
-
src/HTTP/Message.hpp (modified) (1 diff)
-
src/HTTP/Reply.cpp (modified) (1 diff)
-
src/HTTP/Reply.hpp (modified) (1 diff)
-
src/HTTP/Request.hpp (modified) (1 diff)
-
src/HyperTextTransportProtocolService.cpp (modified) (1 diff)
-
src/HyperTextTransportProtocolService.hpp (modified) (2 diffs)
-
src/TCP/Connection.cpp (modified) (7 diffs)
-
src/TCP/Connection.hpp (modified) (1 diff)
-
src/TCP/Message.cpp (modified) (2 diffs)
-
src/TCP/Message.hpp (modified) (1 diff)
-
src/TransmissionControlProtocolService.cpp (modified) (13 diffs)
-
src/TransmissionControlProtocolService.hpp (modified) (2 diffs)
-
src/UDP/Endpoint.cpp (modified) (3 diffs)
-
src/UDP/Endpoint.hpp (modified) (2 diffs)
-
src/UDP/Message.cpp (modified) (2 diffs)
-
src/UDP/Message.hpp (modified) (2 diffs)
-
src/UserDatagramProtocolService.cpp (modified) (3 diffs)
-
src/UserDatagramProtocolService.hpp (modified) (2 diffs)
-
src/XML/Endpoint.cpp (modified) (3 diffs)
-
src/XML/Endpoint.hpp (modified) (2 diffs)
-
src/XML/Message.cpp (modified) (1 diff)
-
src/XML/Message.hpp (modified) (1 diff)
-
src/XML/Reply.cpp (modified) (1 diff)
-
src/XML/Reply.hpp (modified) (1 diff)
-
src/XML/Request.hpp (modified) (1 diff)
-
src/XML/XMLProtocolService.cpp (modified) (1 diff)
-
src/XML/XMLProtocolService.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/UDP/I_Message.hpp
r1264 r3447 46 46 /// Every single message created on the client has a unique message Id. 47 47 /// This method returns that value. 48 virtual unsigned int getMessageID() const = 0;48 virtual boost::uint32_t getMessageID() const = 0; 49 49 50 50 virtual unsigned int getServiceID() const = 0; -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/Endpoint.cpp
r3420 r3447 35 35 #include <Zen/Enterprise/AppServer/I_ProtocolService.hpp> 36 36 37 #include <sstream> 38 37 39 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 38 40 namespace Zen { … … 43 45 : m_pProtocolAdapter(_pProtocolAdapter) 44 46 , m_endpoint(_endpoint) 47 , m_isLocal(true) 45 48 { 49 std::stringstream endpointStream; 50 endpointStream << _endpoint; 51 m_endpointString = endpointStream.str(); 46 52 } 47 53 … … 73 79 74 80 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 81 void 82 Endpoint::setIsLocal(bool _isLocal) 83 { 84 m_isLocal = _isLocal; 85 } 86 87 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 88 bool 89 Endpoint::isLocal() const 90 { 91 return m_isLocal; 92 } 93 94 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 75 95 } // namespace AppServer 76 96 } // namespace Enterprise -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/Endpoint.hpp
r2055 r3447 47 47 public: 48 48 virtual wpProtocolService_type getProtocolAdapter() const; 49 49 virtual const std::string& toString() const { return m_endpointString; } 50 50 virtual const Zen::Networking::I_Address& getAddress() const; 51 virtual void setIsLocal(bool _isLocal); 52 virtual bool isLocal() const; 51 53 /// @} 52 54 … … 71 73 wpProtocolService_type m_pProtocolAdapter; 72 74 boost::asio::ip::tcp::endpoint m_endpoint; 75 bool m_isLocal; 76 std::string m_endpointString; 73 77 /// @} 74 78 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Message.cpp
r3350 r3447 82 82 83 83 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 84 unsigned int 84 boost::uint32_t 85 85 Message::getMessageId() const 86 86 { -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Message.hpp
r3350 r3447 43 43 virtual pEndpoint_type getDestinationEndpoint(); 44 44 virtual pResourceLocation_type getDestinationLocation(); 45 virtual unsigned int getMessageId() const;45 virtual boost::uint32_t getMessageId() const; 46 46 virtual void serialize(boost::archive::polymorphic_iarchive& _archive, const int _version); 47 47 virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Reply.cpp
r3431 r3447 264 264 265 265 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 266 unsigned int266 boost::uint32_t 267 267 Reply::getMessageId() const 268 268 { -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Reply.hpp
r3431 r3447 63 63 virtual pResourceLocation_type getDestinationLocation(); 64 64 virtual pMessageHeader_type getMessageHeader() const; 65 virtual unsigned int getMessageId() const;65 virtual boost::uint32_t getMessageId() const; 66 66 virtual pMessageType_type getMessageType() const; 67 67 virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Request.hpp
r3431 r3447 56 56 virtual pResourceLocation_type getDestinationLocation() { return Message::getDestinationLocation(); } 57 57 virtual pMessageHeader_type getMessageHeader() const; 58 virtual unsigned int getMessageId() const { return Message::getMessageId(); }58 virtual boost::uint32_t getMessageId() const { return Message::getMessageId(); } 59 59 virtual pMessageType_type getMessageType() const; 60 60 virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HyperTextTransportProtocolService.cpp
r3420 r3447 151 151 // This is intentionally not implemented as you cannot use sendTo for HTTP. 152 152 throw Utility::runtime_exception("HyperTextTransportProtocolService::sendTo(): Error, not implemented."); 153 } 154 155 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 156 Event::I_Event& 157 HyperTextTransportProtocolService::getConnectedEvent() 158 { 159 throw Utility::runtime_exception("HyperTextTransportProtocolService::getConnectedEvent(): Error, not implemented."); 160 } 161 162 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 163 Event::I_Event& 164 HyperTextTransportProtocolService::getDisconnectedEvent() 165 { 166 throw Utility::runtime_exception("HyperTextTransportProtocolService::getConnectedEvent(): Error, not implemented."); 153 167 } 154 168 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HyperTextTransportProtocolService.hpp
r2480 r3447 49 49 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 50 50 namespace Zen { 51 namespace Event { 52 class I_Event; 53 } // namespace Event 51 54 namespace Enterprise { 52 55 namespace AppServer { … … 81 84 virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 82 85 virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 86 virtual Event::I_Event& getConnectedEvent(); 87 virtual Event::I_Event& getDisconnectedEvent(); 83 88 /// @} 84 89 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Connection.cpp
r3420 r3447 29 29 #include "../TransmissionControlProtocolService.hpp" 30 30 31 #include <Zen/Core/Threading/MutexFactory.hpp> 31 32 #include <Zen/Core/Utility/runtime_exception.hpp> 33 32 34 #include <Zen/Enterprise/Networking/I_Endpoint.hpp> 33 35 #include <Zen/Enterprise/AppServer/I_Response.hpp> 34 36 35 37 #include <boost/bind.hpp> 38 39 #include <iostream> 36 40 37 41 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ … … 45 49 , m_strand(_ioService) 46 50 , m_protocolService(_protocolService) 51 , m_pPeerEndpoint() 47 52 , m_connected(false) 53 , m_pWriteQueueGuard(Threading::MutexFactory::create()) 48 54 { 49 55 } … … 52 58 Connection::~Connection() 53 59 { 60 Threading::MutexFactory::destroy(m_pWriteQueueGuard); 54 61 // m_pHandler is destroyed in Connection::write() 55 62 } … … 66 73 Connection::connect(pEndpoint_type _pEndpoint) 67 74 { 75 // Connect to a server. 68 76 m_pPeerEndpoint = _pEndpoint; 69 77 … … 150 158 Threading::CriticalSection lock(m_pWriteQueueGuard); 151 159 152 bool writeInProgress = m_writeMessages.empty();160 bool writeInProgress = !m_writeMessages.empty(); 153 161 m_writeMessages.push_back(pMsg); 154 162 … … 198 206 Connection::handleReadBody(const boost::system::error_code& _errorCode) 199 207 { 200 if (!_errorCode && m_readMessage.decodeHeader())208 if (!_errorCode) 201 209 { 202 210 m_protocolService.onHandleMessage(shared_from_this(), m_readMessage); … … 227 235 { 228 236 // The write failed, so don't delete the message 229 237 std::cout << _errorCode.message() << std::endl; 230 238 m_connected = false; 231 239 m_protocolService.onDisconnected(shared_from_this()); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Connection.hpp
r1494 r3447 66 66 /// Connect to an endpoint. 67 67 /// This connection is not connected yet. 68 /// This establishes a TCP connection to a server. 68 69 void connect(pEndpoint_type _pEndpoint); 69 70 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Message.cpp
r1494 r3447 115 115 MessageBuffer::decodeHeader() 116 116 { 117 m_bodyLength = big_to_native(m_ bodyLength);117 m_bodyLength = big_to_native(m_encodedBodyLength); 118 118 if (m_bodyLength > MAX_BODY_LENGTH) 119 119 { … … 129 129 MessageBuffer::encodeHeader() 130 130 { 131 m_ bodyLength = native_to_big(m_bodyLength);131 m_encodedBodyLength = native_to_big(m_bodyLength); 132 132 } 133 133 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Message.hpp
r1494 r3447 71 71 72 72 private: 73 boost::uint32_t m_bodyLength; 73 74 union 74 75 { 75 boost::uint32_t m_ bodyLength;76 boost::uint32_t m_encodedBodyLength; 76 77 char m_data[HEADER_LENGTH + MAX_BODY_LENGTH]; 77 78 }; -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TransmissionControlProtocolService.cpp
r3429 r3447 25 25 #define NOMINMAX 26 26 #endif 27 // This must be included first thanks to some Winblows crap. 27 28 #include <boost/asio.hpp> 28 29 … … 38 39 39 40 #include <Zen/Core/Plugins/I_ConfigurationElement.hpp> 41 42 #include <Zen/Core/Event/I_Event.hpp> 43 #include <Zen/Core/Event/I_EventService.hpp> 40 44 41 45 #include <Zen/Enterprise/AppServer/I_Message.hpp> … … 51 55 #include <boost/archive/polymorphic_binary_oarchive.hpp> 52 56 #include <boost/archive/polymorphic_binary_iarchive.hpp> 57 58 #include <boost/iostreams/device/array.hpp> 59 #include <boost/iostreams/stream.hpp> 53 60 54 61 #include <iostream> … … 112 119 boost::asio::ip::tcp::resolver resolver(m_ioService); 113 120 // TODO _address and _port or v4() and m_port? 114 boost::asio::ip::tcp::resolver::query query( boost::asio::ip::tcp::v4(), m_port);121 boost::asio::ip::tcp::resolver::query query(_address, _port); 115 122 boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query); 116 123 117 return pEndpoint_type(new Endpoint(getSelfReference(), endpoint), boost::bind(&TransmissionControlProtocolService::destroyEndpoint, this, _1)); 124 pEndpoint_type pEndpoint(new Endpoint(getSelfReference(), endpoint), boost::bind(&TransmissionControlProtocolService::destroyEndpoint, this, _1)); 125 126 // Default to true. Generally an endpoint is outbound when resolveEndpoint() 127 // is called. Since "listen()" is not a valid method (listen ports are 128 // determined by the configuration) then we probably aren't ever creating 129 // a non-local endpoint. 130 pEndpoint->setIsLocal(false); 131 return pEndpoint; 118 132 } 119 133 … … 124 138 // TODO Push onto a queue and handle in a worker thread? 125 139 { 126 Threading::CriticalSection lock(m_pConnectionsGuard);127 128 140 typedef Memory::managed_ptr<Endpoint> pConcreteEndpoint_type; 129 141 pConcreteEndpoint_type pEndpoint(_pEndpoint.as<pConcreteEndpoint_type>()); 130 142 131 ConnectionMap_type::iterator iter = m_connectionMap.find(pEndpoint->getEndpoint());132 133 if (iter != m_connectionMap.end())143 pConnection_type pConnection; 144 145 // Find or create the connection. 134 146 { 135 // TODO Create a task to handle this asynchronously? 136 std::stringstream buffer; 137 138 boost::archive::polymorphic_binary_oarchive archive(buffer, 139 boost::archive::no_header | 140 boost::archive::no_tracking); 141 142 // Serialize the header 143 // TODO Handle the version correctly 144 _pMessage->getMessageHeader()->serialize(archive, 0); 145 146 // Serialize the rest of the message 147 _pMessage->serialize(archive, 0); 148 149 iter->second->write(buffer.str().c_str(), (boost::uint32_t)buffer.str().length()); 147 Threading::CriticalSection lock(m_pConnectionsGuard); 148 149 // Find the connection associated with this endpoint. 150 ConnectionMap_type::iterator iter = m_connectionMap.find(pEndpoint->getEndpoint()); 151 152 if (iter == m_connectionMap.end()) 153 { 154 if (m_isServer) 155 { 156 // TODO Error? 157 return; 158 } 159 160 pConnection = m_pNewConnection; 161 162 createConnection(); 163 164 // Assume this is an outbound endpoint. 165 pEndpoint->setIsLocal(false); 166 167 m_connectionMap[pEndpoint->getEndpoint()] = pConnection; 168 pConnection->connect(_pEndpoint); 169 } 170 else 171 { 172 pConnection = iter->second; 173 } 150 174 } 151 else 152 { 153 if (m_isServer) 154 { 155 // TODO Error? 156 return; 157 } 158 159 pConnection_type pConnection = m_pNewConnection; 160 161 createConnection(); 162 163 m_connectionMap[pEndpoint->getEndpoint()] = pConnection; 164 pConnection->connect(_pEndpoint); 165 } 175 176 // TODO Create a task to handle this asynchronously? 177 std::stringstream buffer; 178 179 boost::archive::polymorphic_binary_oarchive archive(buffer, 180 boost::archive::no_header | 181 boost::archive::no_tracking); 182 183 // Serialize the header 184 // TODO Handle the version correctly 185 _pMessage->getMessageHeader()->serialize(archive, 0); 186 187 // Serialize the rest of the message 188 _pMessage->serialize(archive, 0); 189 190 pConnection->write(buffer.str().c_str(), (boost::uint32_t)buffer.str().length()); 191 166 192 } 167 193 168 194 // Make sure the threads have been started. 169 195 startThreads(); 196 } 197 198 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 199 Event::I_Event& 200 TransmissionControlProtocolService::getConnectedEvent() 201 { 202 return getApplicationServer().getEventService()->getEvent("TransmissionControlProtocolService/connectedEvent"); 203 } 204 205 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 206 Event::I_Event& 207 TransmissionControlProtocolService::getDisconnectedEvent() 208 { 209 return getApplicationServer().getEventService()->getEvent("TransmissionControlProtocolService/disconnectedEvent"); 170 210 } 171 211 … … 226 266 // Asyncronously accept a new connection 227 267 asyncAccept(); 228 229 startThreads();230 }268 } 269 270 startThreads(); 231 271 } 232 272 … … 300 340 try 301 341 { 302 m_ioService.run(); 342 boost::system::error_code ec; 343 m_ioService.run(ec); 344 345 if( ec ) 346 { 347 std::cout << "ASIO Error: " << ec << std::endl; 348 } 349 } 350 catch(std::exception& _ex) 351 { 352 std::cout << "Exception in ASIO loop: " << _ex.what() << std::endl; 303 353 } 304 354 catch(...) 305 355 { 356 std::cout << "Unknown exception in ASIO loop" << std::endl; 306 357 } 307 358 } … … 333 384 } 334 385 386 m_threadsStarted = true; 387 335 388 } 336 389 … … 343 396 // The new connection is now connected, so start it. 344 397 pEndpoint_type pEndpoint(new Endpoint(getSelfReference(), m_endpoint), boost::bind(&TransmissionControlProtocolService::destroyEndpoint, this, _1)); 398 399 // This endpoint is not local since it was established from an accept. 400 pEndpoint->setIsLocal(false); 345 401 346 402 m_pNewConnection->start(pEndpoint); … … 396 452 397 453 m_connectionMap.erase(_pConnection->getPeer().as<pConcreteEndpoint_type>()->getEndpoint()); 454 455 // Dispatch this event. 456 getDisconnectedEvent().fireEvent(_pConnection->getPeer()); 398 457 } 399 458 … … 402 461 TransmissionControlProtocolService::onHandleMessage(pConnection_type _pConnection, TCP::MessageBuffer& _message) 403 462 { 404 std::stringbuf buffer; 463 #if 1 464 boost::iostreams::stream<boost::iostreams::array> 465 stream(_message.getBody(), _message.getBodyLength()); 466 467 boost::archive::polymorphic_binary_iarchive archive(stream, 468 boost::archive::no_header | 469 boost::archive::no_tracking); 470 471 472 473 // Deserialize the header 474 I_Message::pMessageHeader_type pHeader = getApplicationServer().getMessageRegistry()->getMessageHeader(archive); 475 476 // Construct the appropriate message 477 // The way we're doing it now, we don't know which one of these to call 478 // create() or createResponse(). 479 // If we put that detail in the header somehow, then we can either call 480 // the correct method... *or* we can let the create() method figure it out. 481 pMessage_type pMessage = pHeader->getMessageType()->getMessageFactory() 482 ->create( 483 pHeader, 484 _pConnection->getPeer(), 485 pEndpoint_type() 486 ); 487 488 // Deserialize the message 489 pMessage->serialize(pHeader, archive, 0); 490 491 // Send the message to the application server 492 getApplicationServer().handleMessage(pMessage); 493 #else 494 std::stringbuf buffer(std::ios_base::in|std::ios_base::binary); 495 405 496 buffer.pubsetbuf(_message.getBody(), _message.getBodyLength()); 406 497 … … 416 507 417 508 // Deserialize the header 418 I_Message::pMessageHeader_type pHeader = m_pMessageRegistry->getMessageHeader(archive);509 I_Message::pMessageHeader_type pHeader = getApplicationServer().getMessageRegistry()->getMessageHeader(archive); 419 510 420 511 // Construct the appropriate message 421 pMessage_type pMessage = pHeader->getMessageType()->getMessageFactory()->create(pHeader, _pConnection->getPeer(), pEndpoint_type()); 512 pMessage_type pMessage = pHeader->getMessageType()->getMessageFactory() 513 ->create( 514 pHeader, 515 _pConnection->getPeer(), 516 pEndpoint_type() 517 ); 422 518 423 519 // Deserialize the message … … 426 522 // Send the message to the application server 427 523 getApplicationServer().handleMessage(pMessage); 524 #endif 428 525 } 429 526 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TransmissionControlProtocolService.hpp
r2480 r3447 74 74 virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 75 75 virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 76 virtual Event::I_Event& getConnectedEvent(); 77 virtual Event::I_Event& getDisconnectedEvent(); 76 78 /// @} 77 79 … … 97 99 void destroyEndpoint(wpEndpoint_type _pEndpoint); 98 100 101 /// This is called by the connection after it has established 102 /// a TCP connection to a server. 99 103 void onConnected(pConnection_type _pConnection); 104 105 /// This is called by the connection after it has lost a 106 /// connection to the server. 100 107 void onDisconnected(pConnection_type _pConnection); 101 108 void onHandleMessage(pConnection_type _pConnection, TCP::MessageBuffer& _message); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Endpoint.cpp
r3420 r3447 32 32 #include <Zen/Enterprise/Networking/I_Address.hpp> 33 33 34 #include <sstream> 35 34 36 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 35 37 namespace Zen { … … 43 45 : m_pProtocolAdapter(_pProtocolAdapter) 44 46 , m_endpoint(_endpoint) 47 , m_isLocal(false) 45 48 { 49 std::stringstream endpointStream; 50 endpointStream << _endpoint; 51 m_endpointString = endpointStream.str(); 46 52 } 47 53 … … 78 84 79 85 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 86 void 87 Endpoint::setIsLocal(bool _isLocal) 88 { 89 m_isLocal = _isLocal; 90 } 91 92 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 93 bool 94 Endpoint::isLocal() const 95 { 96 return m_isLocal; 97 } 98 99 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 80 100 } // namespace UDP 81 101 } // namespace AppServer -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Endpoint.hpp
r2055 r3447 51 51 virtual wpProtocolService_type getProtocolAdapter() const; 52 52 53 virtual const std::string& toString() const { return m_endpointString; } 54 53 55 virtual const Zen::Networking::I_Address& getAddress() const; 56 57 virtual void setIsLocal(bool _isLocal); 58 59 virtual bool isLocal() const; 54 60 /// @} 55 61 … … 73 79 wpProtocolService_type m_pProtocolAdapter; 74 80 boost::asio::ip::udp::endpoint m_endpoint; 81 bool m_isLocal; 82 std::string m_endpointString; 75 83 /// @} 76 84 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Message.cpp
r3420 r3447 103 103 104 104 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 105 unsigned int105 boost::uint32_t 106 106 Message::getMessageID() const 107 107 { … … 110 110 111 111 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 112 unsigned int112 boost::uint32_t 113 113 Message::getNewMessageID() 114 114 { 115 115 static Zen::Threading::SpinLock sm_spinLock; 116 static unsigned int sm_lastID = 0;116 static boost::uint32_t sm_lastID = 0; 117 117 118 118 Zen::Threading::xCriticalSection lock(sm_spinLock); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Message.hpp
r1264 r3447 65 65 /// @{ 66 66 public: 67 virtual unsigned int getMessageID() const;67 virtual boost::uint32_t getMessageID() const; 68 68 69 69 virtual unsigned int getServiceID() const; … … 73 73 /// @{ 74 74 public: 75 static unsigned int getNewMessageID();75 static boost::uint32_t getNewMessageID(); 76 76 /// @} 77 77 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UserDatagramProtocolService.cpp
r3420 r3447 168 168 if( ec ) 169 169 { 170 std::cout << " Error: " << ec << std::endl;170 std::cout << "ASIO Error: " << ec << std::endl; 171 171 } 172 172 } … … 193 193 194 194 m_pWork = new boost::asio::io_service::work(m_ioService); 195 196 // Reserve the correct amount of space. 197 m_threads.reserve(m_threadCount); 195 198 196 199 // Start some threads that will execute m_ioService.run() … … 278 281 279 282 m_pThreadPool->pushRequest(pTask); 283 } 284 285 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 286 Event::I_Event& 287 UserDatagramProtocolService::getConnectedEvent() 288 { 289 throw Utility::runtime_exception("UserDatagramProtocolService::getConnectedEvent(): Error, not implemented."); 290 } 291 292 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 293 Event::I_Event& 294 UserDatagramProtocolService::getDisconnectedEvent() 295 { 296 throw Utility::runtime_exception("UserDatagramProtocolService::getConnectedEvent(): Error, not implemented."); 280 297 } 281 298 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UserDatagramProtocolService.hpp
r1673 r3447 51 51 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 52 52 namespace Zen { 53 namespace Event { 54 class I_Event; 55 } // namespace Event 53 56 namespace Enterprise { 54 57 namespace AppServer { … … 92 95 virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 93 96 virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 97 virtual Event::I_Event& getConnectedEvent(); 98 virtual Event::I_Event& getDisconnectedEvent(); 94 99 /// @} 95 100 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Endpoint.cpp
r3420 r3447 35 35 #include <Zen/Enterprise/AppServer/I_ProtocolService.hpp> 36 36 37 #include <sstream> 38 37 39 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 38 40 namespace Zen { … … 44 46 : m_pProtocolAdapter(_pProtocolAdapter) 45 47 , m_endpoint(_endpoint) 48 , m_isLocal(false) 46 49 { 50 std::stringstream endpointStream; 51 endpointStream << _endpoint; 52 m_endpointString = endpointStream.str(); 47 53 } 48 54 … … 75 81 76 82 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 83 void 84 Endpoint::setIsLocal(bool _isLocal) 85 { 86 m_isLocal = _isLocal; 87 } 88 89 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 90 bool 91 Endpoint::isLocal() const 92 { 93 return m_isLocal; 94 } 95 96 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 77 97 } // namespace XML 78 98 } // namespace AppServer -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Endpoint.hpp
r2055 r3447 51 51 virtual wpProtocolService_type getProtocolAdapter() const; 52 52 53 virtual const std::string& toString() const { return m_endpointString; } 54 53 55 virtual const Zen::Networking::I_Address& getAddress() const; 56 57 virtual void setIsLocal(bool _isLocal); 58 59 virtual bool isLocal() const; 54 60 /// @} 55 61 … … 73 79 wpProtocolService_type m_pProtocolAdapter; 74 80 boost::asio::ip::tcp::endpoint m_endpoint; 81 bool m_isLocal; 82 std::string m_endpointString; 75 83 /// @} 76 84 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Message.cpp
r3420 r3447 86 86 87 87 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 88 unsigned int 88 boost::uint32_t 89 89 Message::getMessageId() const 90 90 { -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Message.hpp
r3350 r3447 45 45 virtual pEndpoint_type getDestinationEndpoint(); 46 46 virtual pResourceLocation_type getDestinationLocation(); 47 virtual unsigned int getMessageId() const;47 virtual boost::uint32_t getMessageId() const; 48 48 virtual void serialize(boost::archive::polymorphic_iarchive& _archive, const int _version); 49 49 virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Reply.cpp
r3431 r3447 162 162 163 163 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 164 unsigned int 164 boost::uint32_t 165 165 Reply::getMessageId() const 166 166 { 167 167 static Zen::Threading::SpinLock sm_spinLock; 168 static unsigned int sm_lastId = 0;168 static boost::uint32_t sm_lastId = 0; 169 169 170 170 Zen::Threading::xCriticalSection lock(sm_spinLock); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Reply.hpp
r3431 r3447 65 65 virtual pResourceLocation_type getDestinationLocation(); 66 66 virtual pMessageHeader_type getMessageHeader() const; 67 virtual unsigned int getMessageId() const;67 virtual boost::uint32_t getMessageId() const; 68 68 virtual pMessageType_type getMessageType() const; 69 69 virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Request.hpp
r3431 r3447 59 59 virtual pMessageHeader_type getMessageHeader() const; 60 60 virtual pMessageType_type getMessageType() const; 61 virtual unsigned int getMessageId() const { return Message::getMessageId(); }61 virtual boost::uint32_t getMessageId() const { return Message::getMessageId(); } 62 62 virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); 63 63 virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/XMLProtocolService.cpp
r3420 r3447 154 154 // TODO Implement 155 155 throw Utility::runtime_exception("XMLProtocolService::sendTo(): Error, not implemented."); 156 } 157 158 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 159 Event::I_Event& 160 XMLProtocolService::getConnectedEvent() 161 { 162 throw Utility::runtime_exception("XMLProtocolService::getConnectedEvent(): Error, not implemented."); 163 } 164 165 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 166 Event::I_Event& 167 XMLProtocolService::getDisconnectedEvent() 168 { 169 throw Utility::runtime_exception("XMLProtocolService::getConnectedEvent(): Error, not implemented."); 156 170 } 157 171 -
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/XMLProtocolService.hpp
r3420 r3447 51 51 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 52 52 namespace Zen { 53 namespace Event { 54 class I_Event; 55 } // namespace Event 53 56 namespace Enterprise { 54 57 namespace AppServer { … … 84 87 virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 85 88 virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 89 virtual Event::I_Event& getConnectedEvent(); 90 virtual Event::I_Event& getDisconnectedEvent(); 86 91 virtual void setMessageRegistry(pMessageRegistry_type _pMessageRegistry); 87 92 /// @}
