Changeset 3447

Show
Ignore:
Timestamp:
02/25/10 17:20:28 (5 months ago)
Author:
mgray
Message:

Debug and refactor of the TCP Protocol Adapter in ZBoostNetworking.

Location:
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking
Files:
31 modified

Legend:

Unmodified
Added
Removed
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/UDP/I_Message.hpp

    r1264 r3447  
    4646    /// Every single message created on the client has a unique message Id. 
    4747    /// This method returns that value. 
    48     virtual unsigned int getMessageID() const = 0; 
     48    virtual boost::uint32_t getMessageID() const = 0; 
    4949 
    5050    virtual unsigned int getServiceID() const = 0; 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/Endpoint.cpp

    r3420 r3447  
    3535#include <Zen/Enterprise/AppServer/I_ProtocolService.hpp> 
    3636 
     37#include <sstream> 
     38 
    3739//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    3840namespace Zen { 
     
    4345:   m_pProtocolAdapter(_pProtocolAdapter) 
    4446,   m_endpoint(_endpoint) 
     47,   m_isLocal(true) 
    4548{ 
     49    std::stringstream endpointStream; 
     50    endpointStream << _endpoint; 
     51    m_endpointString = endpointStream.str(); 
    4652} 
    4753 
     
    7379 
    7480//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     81void 
     82Endpoint::setIsLocal(bool _isLocal) 
     83{ 
     84    m_isLocal = _isLocal; 
     85} 
     86 
     87//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     88bool 
     89Endpoint::isLocal() const 
     90{ 
     91    return m_isLocal; 
     92} 
     93 
     94//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    7595}   // namespace AppServer 
    7696}   // namespace Enterprise 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/Endpoint.hpp

    r2055 r3447  
    4747public: 
    4848    virtual wpProtocolService_type getProtocolAdapter() const; 
    49  
     49    virtual const std::string& toString() const { return m_endpointString; } 
    5050    virtual const Zen::Networking::I_Address& getAddress() const; 
     51    virtual void setIsLocal(bool _isLocal); 
     52    virtual bool isLocal() const; 
    5153    /// @} 
    5254 
     
    7173    wpProtocolService_type          m_pProtocolAdapter; 
    7274    boost::asio::ip::tcp::endpoint  m_endpoint; 
     75    bool                            m_isLocal; 
     76    std::string                     m_endpointString; 
    7377    /// @} 
    7478 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Message.cpp

    r3350 r3447  
    8282 
    8383//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    84 unsigned int  
     84boost::uint32_t 
    8585Message::getMessageId() const 
    8686{ 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Message.hpp

    r3350 r3447  
    4343    virtual pEndpoint_type getDestinationEndpoint(); 
    4444    virtual pResourceLocation_type getDestinationLocation(); 
    45     virtual unsigned int getMessageId() const; 
     45    virtual boost::uint32_t getMessageId() const; 
    4646    virtual void serialize(boost::archive::polymorphic_iarchive& _archive, const int _version); 
    4747    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  
    264264 
    265265//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    266 unsigned int 
     266boost::uint32_t 
    267267Reply::getMessageId() const 
    268268{ 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Reply.hpp

    r3431 r3447  
    6363    virtual pResourceLocation_type getDestinationLocation(); 
    6464    virtual pMessageHeader_type getMessageHeader() const; 
    65     virtual unsigned int getMessageId() const; 
     65    virtual boost::uint32_t getMessageId() const; 
    6666    virtual pMessageType_type getMessageType() const; 
    6767    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  
    5656    virtual pResourceLocation_type getDestinationLocation() { return Message::getDestinationLocation(); } 
    5757    virtual pMessageHeader_type getMessageHeader() const; 
    58     virtual unsigned int getMessageId() const { return Message::getMessageId(); } 
     58    virtual boost::uint32_t getMessageId() const { return Message::getMessageId(); } 
    5959    virtual pMessageType_type getMessageType() const; 
    6060    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  
    151151    // This is intentionally not implemented as you cannot use sendTo for HTTP. 
    152152    throw Utility::runtime_exception("HyperTextTransportProtocolService::sendTo(): Error, not implemented."); 
     153} 
     154 
     155//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     156Event::I_Event& 
     157HyperTextTransportProtocolService::getConnectedEvent() 
     158{ 
     159    throw Utility::runtime_exception("HyperTextTransportProtocolService::getConnectedEvent(): Error, not implemented."); 
     160} 
     161 
     162//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     163Event::I_Event& 
     164HyperTextTransportProtocolService::getDisconnectedEvent() 
     165{ 
     166    throw Utility::runtime_exception("HyperTextTransportProtocolService::getConnectedEvent(): Error, not implemented."); 
    153167} 
    154168 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HyperTextTransportProtocolService.hpp

    r2480 r3447  
    4949//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    5050namespace Zen { 
     51    namespace Event { 
     52        class I_Event; 
     53    }   // namespace Event 
    5154namespace Enterprise { 
    5255namespace AppServer { 
     
    8184    virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 
    8285    virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 
     86    virtual Event::I_Event& getConnectedEvent(); 
     87    virtual Event::I_Event& getDisconnectedEvent(); 
    8388    /// @} 
    8489 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Connection.cpp

    r3420 r3447  
    2929#include "../TransmissionControlProtocolService.hpp" 
    3030 
     31#include <Zen/Core/Threading/MutexFactory.hpp> 
    3132#include <Zen/Core/Utility/runtime_exception.hpp> 
     33 
    3234#include <Zen/Enterprise/Networking/I_Endpoint.hpp> 
    3335#include <Zen/Enterprise/AppServer/I_Response.hpp> 
    3436 
    3537#include <boost/bind.hpp> 
     38 
     39#include <iostream> 
    3640 
    3741//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     
    4549,   m_strand(_ioService) 
    4650,   m_protocolService(_protocolService) 
     51,   m_pPeerEndpoint() 
    4752,   m_connected(false) 
     53,   m_pWriteQueueGuard(Threading::MutexFactory::create()) 
    4854{ 
    4955} 
     
    5258Connection::~Connection() 
    5359{ 
     60    Threading::MutexFactory::destroy(m_pWriteQueueGuard); 
    5461    // m_pHandler is destroyed in Connection::write() 
    5562} 
     
    6673Connection::connect(pEndpoint_type _pEndpoint) 
    6774{ 
     75    // Connect to a server. 
    6876    m_pPeerEndpoint = _pEndpoint; 
    6977 
     
    150158    Threading::CriticalSection lock(m_pWriteQueueGuard); 
    151159 
    152     bool writeInProgress = m_writeMessages.empty(); 
     160    bool writeInProgress = !m_writeMessages.empty(); 
    153161    m_writeMessages.push_back(pMsg); 
    154162 
     
    198206Connection::handleReadBody(const boost::system::error_code& _errorCode) 
    199207{ 
    200     if (!_errorCode && m_readMessage.decodeHeader()) 
     208    if (!_errorCode) 
    201209    { 
    202210        m_protocolService.onHandleMessage(shared_from_this(), m_readMessage); 
     
    227235    { 
    228236        // The write failed, so don't delete the message 
    229  
     237        std::cout << _errorCode.message() << std::endl; 
    230238        m_connected = false; 
    231239        m_protocolService.onDisconnected(shared_from_this()); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Connection.hpp

    r1494 r3447  
    6666    /// Connect to an endpoint. 
    6767    /// This connection is not connected yet. 
     68    /// This establishes a TCP connection to a server. 
    6869    void connect(pEndpoint_type _pEndpoint); 
    6970 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Message.cpp

    r1494 r3447  
    115115MessageBuffer::decodeHeader() 
    116116{ 
    117     m_bodyLength = big_to_native(m_bodyLength); 
     117    m_bodyLength = big_to_native(m_encodedBodyLength); 
    118118    if (m_bodyLength > MAX_BODY_LENGTH) 
    119119    { 
     
    129129MessageBuffer::encodeHeader() 
    130130{ 
    131     m_bodyLength = native_to_big(m_bodyLength); 
     131    m_encodedBodyLength = native_to_big(m_bodyLength); 
    132132} 
    133133 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TCP/Message.hpp

    r1494 r3447  
    7171 
    7272private: 
     73    boost::uint32_t                     m_bodyLength; 
    7374    union 
    7475    { 
    75         boost::uint32_t                 m_bodyLength; 
     76        boost::uint32_t                 m_encodedBodyLength; 
    7677        char                            m_data[HEADER_LENGTH + MAX_BODY_LENGTH]; 
    7778    }; 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TransmissionControlProtocolService.cpp

    r3429 r3447  
    2525#define NOMINMAX 
    2626#endif 
     27// This must be included first thanks to some Winblows crap. 
    2728#include <boost/asio.hpp> 
    2829 
     
    3839 
    3940#include <Zen/Core/Plugins/I_ConfigurationElement.hpp> 
     41 
     42#include <Zen/Core/Event/I_Event.hpp> 
     43#include <Zen/Core/Event/I_EventService.hpp> 
    4044 
    4145#include <Zen/Enterprise/AppServer/I_Message.hpp> 
     
    5155#include <boost/archive/polymorphic_binary_oarchive.hpp> 
    5256#include <boost/archive/polymorphic_binary_iarchive.hpp> 
     57 
     58#include <boost/iostreams/device/array.hpp> 
     59#include <boost/iostreams/stream.hpp> 
    5360 
    5461#include <iostream> 
     
    112119    boost::asio::ip::tcp::resolver resolver(m_ioService); 
    113120    // 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); 
    115122    boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query); 
    116123 
    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; 
    118132} 
    119133 
     
    124138    // TODO Push onto a queue and handle in a worker thread? 
    125139    { 
    126         Threading::CriticalSection lock(m_pConnectionsGuard); 
    127  
    128140        typedef Memory::managed_ptr<Endpoint> pConcreteEndpoint_type; 
    129141        pConcreteEndpoint_type pEndpoint(_pEndpoint.as<pConcreteEndpoint_type>()); 
    130142 
    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. 
    134146        { 
    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            } 
    150174        } 
    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 
    166192    } 
    167193 
    168194    // Make sure the threads have been started. 
    169195    startThreads(); 
     196} 
     197 
     198//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     199Event::I_Event& 
     200TransmissionControlProtocolService::getConnectedEvent() 
     201{ 
     202    return getApplicationServer().getEventService()->getEvent("TransmissionControlProtocolService/connectedEvent"); 
     203} 
     204 
     205//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     206Event::I_Event& 
     207TransmissionControlProtocolService::getDisconnectedEvent() 
     208{ 
     209    return getApplicationServer().getEventService()->getEvent("TransmissionControlProtocolService/disconnectedEvent"); 
    170210} 
    171211 
     
    226266        // Asyncronously accept a new connection 
    227267        asyncAccept(); 
    228  
    229         startThreads(); 
    230     } 
     268    } 
     269     
     270    startThreads(); 
    231271} 
    232272 
     
    300340                try 
    301341                { 
    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; 
    303353                } 
    304354                catch(...) 
    305355                { 
     356                    std::cout << "Unknown exception in ASIO loop" << std::endl; 
    306357                } 
    307358            } 
     
    333384    } 
    334385 
     386    m_threadsStarted = true; 
     387 
    335388} 
    336389 
     
    343396        // The new connection is now connected, so start it. 
    344397        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); 
    345401 
    346402        m_pNewConnection->start(pEndpoint); 
     
    396452 
    397453    m_connectionMap.erase(_pConnection->getPeer().as<pConcreteEndpoint_type>()->getEndpoint()); 
     454 
     455    // Dispatch this event. 
     456    getDisconnectedEvent().fireEvent(_pConnection->getPeer()); 
    398457} 
    399458 
     
    402461TransmissionControlProtocolService::onHandleMessage(pConnection_type  _pConnection, TCP::MessageBuffer& _message) 
    403462{ 
    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 
    405496    buffer.pubsetbuf(_message.getBody(), _message.getBodyLength()); 
    406497 
     
    416507     
    417508    // Deserialize the header 
    418     I_Message::pMessageHeader_type pHeader = m_pMessageRegistry->getMessageHeader(archive); 
     509    I_Message::pMessageHeader_type pHeader = getApplicationServer().getMessageRegistry()->getMessageHeader(archive); 
    419510 
    420511    // 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        ); 
    422518 
    423519    // Deserialize the message 
     
    426522    // Send the message to the application server 
    427523    getApplicationServer().handleMessage(pMessage); 
     524#endif 
    428525} 
    429526 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/TransmissionControlProtocolService.hpp

    r2480 r3447  
    7474    virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 
    7575    virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 
     76    virtual Event::I_Event& getConnectedEvent(); 
     77    virtual Event::I_Event& getDisconnectedEvent(); 
    7678    /// @} 
    7779 
     
    9799    void destroyEndpoint(wpEndpoint_type _pEndpoint); 
    98100 
     101    /// This is called by the connection after it has established 
     102    /// a TCP connection to a server. 
    99103    void onConnected(pConnection_type _pConnection); 
     104 
     105    /// This is called by the connection after it has lost a 
     106    /// connection to the server. 
    100107    void onDisconnected(pConnection_type _pConnection); 
    101108    void onHandleMessage(pConnection_type  _pConnection, TCP::MessageBuffer& _message); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Endpoint.cpp

    r3420 r3447  
    3232#include <Zen/Enterprise/Networking/I_Address.hpp> 
    3333 
     34#include <sstream> 
     35 
    3436//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    3537namespace Zen { 
     
    4345:   m_pProtocolAdapter(_pProtocolAdapter) 
    4446,   m_endpoint(_endpoint) 
     47,   m_isLocal(false) 
    4548{ 
     49    std::stringstream endpointStream; 
     50    endpointStream << _endpoint; 
     51    m_endpointString = endpointStream.str(); 
    4652} 
    4753 
     
    7884 
    7985//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     86void 
     87Endpoint::setIsLocal(bool _isLocal) 
     88{ 
     89    m_isLocal = _isLocal; 
     90} 
     91 
     92//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     93bool 
     94Endpoint::isLocal() const 
     95{ 
     96    return m_isLocal; 
     97} 
     98 
     99//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    80100}   // namespace UDP 
    81101}   // namespace AppServer 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Endpoint.hpp

    r2055 r3447  
    5151    virtual wpProtocolService_type getProtocolAdapter() const; 
    5252 
     53    virtual const std::string& toString() const { return m_endpointString; } 
     54 
    5355    virtual const Zen::Networking::I_Address& getAddress() const; 
     56 
     57    virtual void setIsLocal(bool _isLocal); 
     58 
     59    virtual bool isLocal() const; 
    5460    /// @} 
    5561 
     
    7379    wpProtocolService_type          m_pProtocolAdapter; 
    7480    boost::asio::ip::udp::endpoint  m_endpoint; 
     81    bool                            m_isLocal; 
     82    std::string                     m_endpointString; 
    7583    /// @} 
    7684 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Message.cpp

    r3420 r3447  
    103103 
    104104//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    105 unsigned int 
     105boost::uint32_t 
    106106Message::getMessageID() const 
    107107{ 
     
    110110 
    111111//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    112 unsigned int 
     112boost::uint32_t 
    113113Message::getNewMessageID() 
    114114{ 
    115115    static Zen::Threading::SpinLock sm_spinLock; 
    116     static unsigned int sm_lastID = 0; 
     116    static boost::uint32_t sm_lastID = 0; 
    117117 
    118118    Zen::Threading::xCriticalSection lock(sm_spinLock); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UDP/Message.hpp

    r1264 r3447  
    6565    /// @{ 
    6666public: 
    67     virtual unsigned int getMessageID() const; 
     67    virtual boost::uint32_t getMessageID() const; 
    6868 
    6969    virtual unsigned int getServiceID() const; 
     
    7373    /// @{ 
    7474public: 
    75     static unsigned int getNewMessageID(); 
     75    static boost::uint32_t getNewMessageID(); 
    7676    /// @} 
    7777 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UserDatagramProtocolService.cpp

    r3420 r3447  
    168168                    if( ec ) 
    169169                    { 
    170                         std::cout << "Error: " << ec << std::endl; 
     170                        std::cout << "ASIO Error: " << ec << std::endl; 
    171171                    } 
    172172                } 
     
    193193 
    194194    m_pWork = new boost::asio::io_service::work(m_ioService); 
     195 
     196    // Reserve the correct amount of space. 
     197    m_threads.reserve(m_threadCount); 
    195198 
    196199    // Start some threads that will execute m_ioService.run() 
     
    278281 
    279282    m_pThreadPool->pushRequest(pTask); 
     283} 
     284 
     285//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     286Event::I_Event& 
     287UserDatagramProtocolService::getConnectedEvent() 
     288{ 
     289    throw Utility::runtime_exception("UserDatagramProtocolService::getConnectedEvent(): Error, not implemented."); 
     290} 
     291 
     292//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     293Event::I_Event& 
     294UserDatagramProtocolService::getDisconnectedEvent() 
     295{ 
     296    throw Utility::runtime_exception("UserDatagramProtocolService::getConnectedEvent(): Error, not implemented."); 
    280297} 
    281298 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/UserDatagramProtocolService.hpp

    r1673 r3447  
    5151//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    5252namespace Zen { 
     53    namespace Event { 
     54        class I_Event; 
     55    }   // namespace Event 
    5356namespace Enterprise { 
    5457namespace AppServer { 
     
    9295    virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 
    9396    virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 
     97    virtual Event::I_Event& getConnectedEvent(); 
     98    virtual Event::I_Event& getDisconnectedEvent(); 
    9499    /// @} 
    95100 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Endpoint.cpp

    r3420 r3447  
    3535#include <Zen/Enterprise/AppServer/I_ProtocolService.hpp> 
    3636 
     37#include <sstream> 
     38 
    3739//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    3840namespace Zen { 
     
    4446:   m_pProtocolAdapter(_pProtocolAdapter) 
    4547,   m_endpoint(_endpoint) 
     48,   m_isLocal(false) 
    4649{ 
     50    std::stringstream endpointStream; 
     51    endpointStream << _endpoint; 
     52    m_endpointString = endpointStream.str(); 
    4753} 
    4854 
     
    7581 
    7682//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     83void 
     84Endpoint::setIsLocal(bool _isLocal) 
     85{ 
     86    m_isLocal = _isLocal; 
     87} 
     88 
     89//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     90bool 
     91Endpoint::isLocal() const 
     92{ 
     93    return m_isLocal; 
     94} 
     95 
     96//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    7797}   // namespace XML 
    7898}   // namespace AppServer 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Endpoint.hpp

    r2055 r3447  
    5151    virtual wpProtocolService_type getProtocolAdapter() const; 
    5252 
     53    virtual const std::string& toString() const { return m_endpointString; } 
     54 
    5355    virtual const Zen::Networking::I_Address& getAddress() const; 
     56 
     57    virtual void setIsLocal(bool _isLocal); 
     58 
     59    virtual bool isLocal() const; 
    5460    /// @} 
    5561 
     
    7379    wpProtocolService_type          m_pProtocolAdapter; 
    7480    boost::asio::ip::tcp::endpoint  m_endpoint; 
     81    bool                            m_isLocal; 
     82    std::string                     m_endpointString; 
    7583    /// @} 
    7684 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Message.cpp

    r3420 r3447  
    8686 
    8787//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    88 unsigned int  
     88boost::uint32_t 
    8989Message::getMessageId() const 
    9090{ 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Message.hpp

    r3350 r3447  
    4545    virtual pEndpoint_type getDestinationEndpoint(); 
    4646    virtual pResourceLocation_type getDestinationLocation(); 
    47     virtual unsigned int getMessageId() const; 
     47    virtual boost::uint32_t getMessageId() const; 
    4848    virtual void serialize(boost::archive::polymorphic_iarchive& _archive, const int _version); 
    4949    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  
    162162 
    163163//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    164 unsigned int  
     164boost::uint32_t 
    165165Reply::getMessageId() const 
    166166{ 
    167167    static Zen::Threading::SpinLock sm_spinLock; 
    168     static unsigned int sm_lastId = 0; 
     168    static boost::uint32_t sm_lastId = 0; 
    169169 
    170170    Zen::Threading::xCriticalSection lock(sm_spinLock); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Reply.hpp

    r3431 r3447  
    6565    virtual pResourceLocation_type getDestinationLocation(); 
    6666    virtual pMessageHeader_type getMessageHeader() const; 
    67     virtual unsigned int getMessageId() const; 
     67    virtual boost::uint32_t getMessageId() const; 
    6868    virtual pMessageType_type getMessageType() const; 
    6969    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  
    5959    virtual pMessageHeader_type getMessageHeader() const; 
    6060    virtual pMessageType_type getMessageType() const; 
    61     virtual unsigned int getMessageId() const { return Message::getMessageId(); } 
     61    virtual boost::uint32_t getMessageId() const { return Message::getMessageId(); } 
    6262    virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); 
    6363    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  
    154154    // TODO Implement 
    155155    throw Utility::runtime_exception("XMLProtocolService::sendTo(): Error, not implemented."); 
     156} 
     157 
     158//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     159Event::I_Event& 
     160XMLProtocolService::getConnectedEvent() 
     161{ 
     162    throw Utility::runtime_exception("XMLProtocolService::getConnectedEvent(): Error, not implemented."); 
     163} 
     164 
     165//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     166Event::I_Event& 
     167XMLProtocolService::getDisconnectedEvent() 
     168{ 
     169    throw Utility::runtime_exception("XMLProtocolService::getConnectedEvent(): Error, not implemented."); 
    156170} 
    157171 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/XMLProtocolService.hpp

    r3420 r3447  
    5151//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    5252namespace Zen { 
     53    namespace Event { 
     54        class I_Event; 
     55    }   // namespace Event 
    5356namespace Enterprise { 
    5457namespace AppServer { 
     
    8487    virtual pEndpoint_type resolveEndpoint(const std::string& _address, const std::string& _port); 
    8588    virtual void sendTo(pMessage_type _pMessage, pEndpoint_type _pEndpoint); 
     89    virtual Event::I_Event& getConnectedEvent(); 
     90    virtual Event::I_Event& getDisconnectedEvent(); 
    8691    virtual void setMessageRegistry(pMessageRegistry_type _pMessageRegistry); 
    8792    /// @}