Changeset 157:e7bd4484bb70 in finroc_plugins_tcp


Ignore:
Timestamp:
31.05.2017 23:37:53 (2 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Applies rework on how different connection partners agree on serialization in input and output streams

File:
1 edited

Legend:

Unmodified
Added
Removed
  • internal/tConnection.cpp

    r156 r157  
    7575static const size_t cMAX_MESSAGE_BATCH_SIZE = 300000000; // more than 30 MB 
    7676 
     77/** Serialization info for initial message */ 
     78static const rrlib::serialization::tSerializationInfo cINITIAL_SERIALIZATION_INFO(0, rrlib::serialization::tRegisterEntryEncoding::UID, network_transport::runtime_info::cDEBUG_PROTOCOL); 
     79 
    7780//---------------------------------------------------------------------- 
    7881// Implementation 
     
    118121  { 
    119122    rrlib::serialization::tOutputStream stream1((*initial_message_buffers)[0]); 
    120     rrlib::serialization::tOutputStream stream2((*initial_message_buffers)[1]); 
     123    rrlib::serialization::tOutputStream stream2((*initial_message_buffers)[1], cINITIAL_SERIALIZATION_INFO); 
    121124    stream1 << cGREET_MESSAGE; 
    122125    stream1.WriteShort(network_transport::generic_protocol::cPROTOCOL_VERSION_MAJOR); 
     
    184187    { 
    185188      rrlib::serialization::tMemoryBuffer read_buffer(initial_message_buffer->begin(), bytes_transferred); 
    186       rrlib::serialization::tInputStream stream(read_buffer, connection->SharedConnectionInfo().input_stream_prototype); 
     189      rrlib::serialization::tInputStream stream(read_buffer, cINITIAL_SERIALIZATION_INFO); 
    187190      if (!first_message_received) 
    188191      { 
     
    228231        bool primary_connection = connection->flags & static_cast<uint>(tConnectionFlag::PRIMARY_CONNECTION); 
    229232        bool express_only_connection = (connection->flags & static_cast<uint>(tConnectionFlag::EXPRESS_DATA)) && (!primary_connection); 
    230         rrlib::serialization::tSerializationInfo input_info(std::min<uint>(network_transport::generic_protocol::cPROTOCOL_VERSION_MINOR, static_cast<uint>(message.Get<4>()) >> 16), 
    231             rrlib::serialization::tRegisterEntryEncoding::UID, 
    232             static_cast<int>(message.Get<3>()) | (java_partner ? network_transport::runtime_info::cJAVA_CLIENT : 0) | (connection->flags & static_cast<uint>(tConnectionFlag::NO_DEBUG) ? 0 : network_transport::runtime_info::cDEBUG_PROTOCOL)); 
    233         input_info.SetRegisterEntryEncoding(static_cast<uint>(network_transport::runtime_info::tRegisterUIDs::TYPE), rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_CHANGE); 
     233        uint serialization_revision = std::min<uint>(network_transport::generic_protocol::cPROTOCOL_VERSION_MINOR, static_cast<uint>(message.Get<4>()) >> 16); 
     234        bool debug_tcp = serialization_revision || (!((!connection->peer.par_debug_tcp.Get()) || (connection->flags & static_cast<uint>(tConnectionFlag::NO_DEBUG)))); 
     235        rrlib::serialization::tSerializationInfo serialization_info(serialization_revision, rrlib::serialization::tRegisterEntryEncoding::UID, static_cast<int>(message.Get<3>()) | (java_partner ? network_transport::runtime_info::cJAVA_CLIENT : 0) | (debug_tcp ? network_transport::runtime_info::cDEBUG_PROTOCOL : 0)); 
     236        rrlib::serialization::tSerializationInfo deserialization_info(serialization_revision, rrlib::serialization::tRegisterEntryEncoding::UID, static_cast<int>(tStructureExchange::SHARED_PORTS) | (debug_tcp ? network_transport::runtime_info::cDEBUG_PROTOCOL : 0)); 
     237        serialization_info.SetRegisterEntryEncoding(static_cast<uint>(network_transport::runtime_info::tRegisterUIDs::TYPE), rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_CHANGE); 
     238        deserialization_info.SetRegisterEntryEncoding(static_cast<uint>(network_transport::runtime_info::tRegisterUIDs::TYPE), rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_CHANGE); 
     239 
    234240        auto& unused_initialization_buffer = connection->peer.UnusedInitializationBuffer(); 
    235         connection->SharedConnectionInfo().input_stream_prototype.Reset(unused_initialization_buffer, input_info); 
    236241 
    237242        if (java_partner) 
    238243        { 
    239           rrlib::serialization::tSerializationInfo output_info(input_info.revision, rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_CHANGE, input_info.custom_info); 
    240           input_info.SetRegisterEntryEncoding(static_cast<uint>(network_transport::runtime_info::tRegisterUIDs::CREATE_ACTION), rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_DEMAND); 
    241           connection->SharedConnectionInfo().output_stream_prototype.Reset(unused_initialization_buffer, output_info); 
    242         } 
    243         else if (input_info.revision == 0) 
    244         { 
    245           input_info.custom_info = static_cast<uint>(network_transport::runtime_info::tStructureExchange::SHARED_PORTS) | network_transport::runtime_info::cDEBUG_PROTOCOL; 
    246           connection->SharedConnectionInfo().output_stream_prototype.Reset(unused_initialization_buffer, input_info); 
    247         } 
    248         else 
    249         { 
    250           input_info.custom_info = static_cast<uint>(network_transport::runtime_info::tStructureExchange::SHARED_PORTS) | (connection->peer.par_debug_tcp.Get() ? network_transport::runtime_info::cDEBUG_PROTOCOL : 0); 
    251           connection->SharedConnectionInfo().output_stream_prototype.Reset(unused_initialization_buffer, input_info); 
    252         } 
     244          serialization_info.SetRegisterEntryEncoding(static_cast<uint>(network_transport::runtime_info::tRegisterUIDs::CONVERSION_OPERATION), rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_CHANGE); 
     245          serialization_info.SetRegisterEntryEncoding(static_cast<uint>(network_transport::runtime_info::tRegisterUIDs::STATIC_CAST), rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_CHANGE); 
     246          serialization_info.SetRegisterEntryEncoding(static_cast<uint>(network_transport::runtime_info::tRegisterUIDs::SCHEME_HANDLER), rrlib::serialization::tRegisterEntryEncoding::PUBLISH_REGISTER_ON_CHANGE); 
     247        } 
     248        connection->SharedConnectionInfo().input_stream_prototype.Reset(unused_initialization_buffer, deserialization_info); 
     249        connection->SharedConnectionInfo().output_stream_prototype.Reset(unused_initialization_buffer, serialization_info); 
     250 
    253251        connection->InitFrontBuffer(); 
    254252 
     
    501499        if (relevant) 
    502500        { 
    503           stream.WriteInt(framework_element_buffer[i]->GetHandle()); 
    504501          network_transport::runtime_info::tLocalFrameworkElementInfo::Serialize(stream, *framework_element_buffer[i], connection->GetRemoteRuntime()->GetDesiredStructureInfo() == tStructureExchange::FINSTRUCT); 
    505502          FINROC_LOG_PRINT(DEBUG_VERBOSE_2, "Serializing ", *framework_element_buffer[i]); 
Note: See TracChangeset for help on using the changeset viewer.