Protocol* ServicePort::make_protocol(bool checksummed, NetworkMessage& msg) const { uint8_t protocolId = msg.GetByte(); for(std::vector<Service_ptr>::const_iterator it = m_services.begin(); it != m_services.end(); ++it) { Service_ptr service = *it; if(service->get_protocol_identifier() == protocolId && ((checksummed && service->is_checksummed()) || !service->is_checksummed())){ // Correct service! Create protocol and get on with it return service->make_protocol(Connection_ptr()); } // We can ignore the other cases, they will most likely end up in return NULL anyways. } return NULL; }
Protocol* ServicePort::make_protocol(bool checksummed, NetworkMessage& msg) const { uint8_t protocolID = msg.GetByte(); for (std::vector<Service_ptr>::const_iterator service_iter = m_services.begin(); service_iter != m_services.end(); ++service_iter) { Service_ptr service = *service_iter; if (protocolID != service->get_protocol_identifier()) { continue; } if ((checksummed && service->is_checksummed()) || !service->is_checksummed()) { return service->make_protocol(Connection_ptr()); } } return NULL; }