void MDNetworkParticipant::network_datagram(Datagram &dg) { DatagramIterator dgi(dg); unsigned short channels = dgi.read_uint8(); if(channels == 1 && dgi.read_uint64() == CONTROL_MESSAGE) { unsigned short msg_type = dgi.read_uint16(); switch(msg_type) { case CONTROL_ADD_CHANNEL: { subscribe_channel(dgi.read_uint64()); } break; case CONTROL_REMOVE_CHANNEL: { unsubscribe_channel(dgi.read_uint64()); } break; case CONTROL_ADD_RANGE: { channel_t lo = dgi.read_uint64(); channel_t hi = dgi.read_uint64(); subscribe_range(lo, hi); } break; case CONTROL_REMOVE_RANGE: { channel_t lo = dgi.read_uint64(); channel_t hi = dgi.read_uint64(); unsubscribe_range(lo, hi); } break; case CONTROL_ADD_POST_REMOVE: { add_post_remove(dgi.read_string()); } break; case CONTROL_CLEAR_POST_REMOVE: { clear_post_removes(); } break; default: logger().error() << "MDNetworkParticipant got unknown control message, type : " << msg_type << std::endl; } return; } send(dg); }
void MDNetworkParticipant::receive_datagram(DatagramHandle dg) { DatagramIterator dgi(dg); uint16_t channels = dgi.read_uint8(); if(channels == 1 && dgi.read_channel() == CONTROL_MESSAGE) { uint16_t msg_type = dgi.read_uint16(); switch(msg_type) { case CONTROL_ADD_CHANNEL: { subscribe_channel(dgi.read_channel()); break; } case CONTROL_REMOVE_CHANNEL: { unsubscribe_channel(dgi.read_channel()); break; } case CONTROL_ADD_RANGE: { channel_t lo = dgi.read_channel(); channel_t hi = dgi.read_channel(); subscribe_range(lo, hi); break; } case CONTROL_REMOVE_RANGE: { channel_t lo = dgi.read_channel(); channel_t hi = dgi.read_channel(); unsubscribe_range(lo, hi); break; } case CONTROL_ADD_POST_REMOVE: { add_post_remove(dgi.read_datagram()); break; } case CONTROL_CLEAR_POST_REMOVE: { clear_post_removes(); break; } case CONTROL_SET_CON_NAME: { set_con_name(dgi.read_string()); break; } case CONTROL_SET_CON_URL: { set_con_url(dgi.read_string()); break; } default: logger().error() << "MDNetworkParticipant got unknown control message, type : " << msg_type << std::endl; } return; } route_datagram(dg); }