SignalFrame SignalFrame::get_reply () const { cf3_assert( node.is_valid() ); const char * frame_tag = Protocol::Tags::node_frame(); XmlNode reply( node.content->next_sibling(frame_tag) ); for( ; reply.is_valid() ; reply.content = reply.content->next_sibling(frame_tag) ) { rapidxml::xml_attribute<>* attr = reply.content->first_attribute( "type" ); if( attr != nullptr && std::strcmp(attr->value(), Protocol::Tags::node_type_reply()) == 0 ) return SignalFrame(reply); } return SignalFrame(); }
SignalFrame & SignalFrame::map ( const std::string & name ) { cf3_assert ( node.is_valid() ); cf3_assert ( !name.empty() ); if( m_maps.find(name) == m_maps.end() ) // if the node does not exist yet, we create it { XmlNode node = main_map.content.add_node( Protocol::Tags::node_value() ); node.set_attribute( Protocol::Tags::attr_key(), name ); m_maps[name] = SignalFrame(node); // SignalFrame() adds a map under the node } return m_maps[name]; }
void ServerNetworkComm::callback_accept( TCPConnection::Ptr conn, const boost::system::error_code & error ) { if( !error ) { // create client info ClientInfo& info = m_clients[conn]; info.connection = conn; info.buffer = SignalFrame( "message", "cpath:/", "cpath:/" ); info.error_handler = boost::shared_ptr<ErrorHandler>(new ErrorHandler()); info.connection->set_error_handler( info.error_handler ); CFinfo << "New client connected from " << conn->socket().remote_endpoint().address() << CFendl; init_read( info ); // init read operation for the new client init_accept(); // wait for other clients } else CFinfo << "Failed to accept a client connection: " << error.message() << CFendl; }