diff --git a/libshvchainpack/src/rpcdriver.cpp b/libshvchainpack/src/rpcdriver.cpp index f5ee9c24..cede7aa9 100644 --- a/libshvchainpack/src/rpcdriver.cpp +++ b/libshvchainpack/src/rpcdriver.cpp @@ -94,6 +94,9 @@ void RpcDriver::setDefaultRpcTimeoutMsec(int msec) void RpcDriver::onRpcFrameReceived(RpcFrame &&frame) { + if (m_clientProtocolType == Rpc::ProtocolType::Invalid) { + m_clientProtocolType = frame.protocol; + } std::string errmsg; auto msg = frame.toRpcMessage(&errmsg); if (errmsg.empty()) { diff --git a/libshviotqt/src/rpc/socket.cpp b/libshviotqt/src/rpc/socket.cpp index eba82884..83d9b4c0 100644 --- a/libshviotqt/src/rpc/socket.cpp +++ b/libshviotqt/src/rpc/socket.cpp @@ -75,14 +75,14 @@ int FrameReader::tryToReadMeta(std::istringstream &in) static constexpr auto protocol_chainpack = static_cast(shv::chainpack::Rpc::ProtocolType::ChainPack); static constexpr auto protocol_cpon = static_cast(shv::chainpack::Rpc::ProtocolType::Cpon); auto protocol = in.get(); - AbstractStreamReader *rd = nullptr; + std::unique_ptr rd; if (protocol == protocol_cpon) { m_protocol = shv::chainpack::Rpc::ProtocolType::Cpon; - rd = new chainpack::CponReader(in); + rd = std::make_unique(in); } else if (protocol == protocol_chainpack) { m_protocol = shv::chainpack::Rpc::ProtocolType::ChainPack; - rd = new chainpack::ChainPackReader(in); + rd = std::make_unique(in); } if (rd) { try {