void rpc_DataSink( CRpcIo & rpc_io, uint32_t size ) { if( size == 0 ) return; CBuffer buffer( size ); rpc_io.Read( &buffer, size ); }
void rpcMessage::Receive(CRpcIo &rpc_io) { m_pos = 0; rpc_io.Read(&m_type, 1); if (m_type == RPC_TYPE_DTB) {} else if (m_type == RPC_TYPE_DTB_DATA) { // remove unexpected data message from queue uint16_t size = 0; rpc_io.Read(&size, 3); rpc_DataSink(rpc_io, size); throw CRpcError(CRpcError::NO_CMD_MSG); } else if (m_type == RPC_TYPE_DTB_DATA_OLD) { // remove unexpected old data message from queue uint8_t chn; uint16_t size; rpc_io.Read(&chn, 1); rpc_io.Read(&size, 2); rpc_DataSink(rpc_io, size); throw CRpcError(CRpcError::NO_CMD_MSG); } else throw CRpcError(CRpcError::WRONG_MSG_TYPE); rpc_io.Read(&m_cmd, 2); rpc_io.Read(&m_size, 1); if (m_size) rpc_io.Read(m_par, m_size); }
void CDataHeader::RecvHeader(CRpcIo &rpc_io) { rpc_io.Read(&m_type, 1); if (m_type == RPC_TYPE_DTB_DATA) {} else if (m_type == RPC_TYPE_DTB) { // remove unexpected command message from queue uint16_t cmd; uint8_t size; rpc_io.Read(&cmd, 2); rpc_io.Read(&size, 1); rpc_DataSink(rpc_io, size); throw CRpcError(CRpcError::NO_DATA_MSG); } else if (m_type == RPC_TYPE_DTB_DATA_OLD) { // remove unexpected old data message from queue uint8_t chn; uint16_t size; rpc_io.Read(&chn, 1); rpc_io.Read(&size, 2); rpc_DataSink(rpc_io, size); throw CRpcError(CRpcError::NO_CMD_MSG); } else throw CRpcError(CRpcError::WRONG_MSG_TYPE); m_size = 0; rpc_io.Read(&m_size, 3); }
void rpc_Receive(CRpcIo &rpc_io, string &x) { CDataHeader msg; msg.RecvHeader(rpc_io); x.clear(); x.reserve(msg.m_size); char ch; for (uint32_t i=0; i<msg.m_size; i++) { rpc_io.Read(&ch, 1); x.push_back(ch); } }
void rpc_Receive( CRpcIo & rpc_io, string & x ) { CDataHeader msg; msg.RecvHeader( rpc_io ); x.clear( ); x.reserve( msg.m_size ); //std::cout << "rpc_Receive " << msg.m_size << " bytes" << std::endl; char ch; for( uint32_t i = 0; i < msg.m_size; i++ ) { rpc_io.Read( &ch, 1 ); // usb.cpp Read x.push_back( ch ); } }