예제 #1
0
bool ServicePort::add_service(Service_ptr new_svc)
{
	for(std::vector<Service_ptr>::const_iterator svc_iter = m_services.begin(); svc_iter != m_services.end(); ++svc_iter){
		Service_ptr svc = *svc_iter;
		if(svc->is_single_socket())
			return false;
	}

	m_services.push_back(new_svc);
	return true;
}
예제 #2
0
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;
}
예제 #3
0
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;
}
예제 #4
0
파일: TestC.cpp 프로젝트: esohns/ATCD
Test::Service_ptr
Test::Service::_duplicate (Service_ptr obj)
{
  if (! ::CORBA::is_nil (obj))
    {
      obj->_add_ref ();
    }
  return obj;
}
예제 #5
0
void ServicePort::onAccept(boost::asio::ip::tcp::socket* socket, const boost::system::error_code& error)
{
	if (!error) {
		if (m_services.empty()) {
			return;
		}

		boost::system::error_code socketError;
		const boost::asio::ip::tcp::endpoint endpoint = socket->remote_endpoint(socketError);

		uint32_t remote_ip = 0;
		if (!socketError) {
			remote_ip = htonl(endpoint.address().to_v4().to_ulong());
		}

		if (remote_ip != 0 && g_bans.acceptConnection(remote_ip)) {
			Connection_ptr connection = ConnectionManager::getInstance()->createConnection(socket, m_io_service, shared_from_this());
			Service_ptr service = m_services.front();

			if (service->is_single_socket()) {
				connection->acceptConnection(service->make_protocol(connection));
			} else {
				connection->acceptConnection();
			}
		} else if (socket->is_open()) {
			socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both, socketError);
			socket->close(socketError);
			delete socket;
		}

		accept();
	} else if (error != boost::asio::error::operation_aborted) {
		if (!m_pendingStart) {
			close();
			m_pendingStart = true;
			g_scheduler.addEvent(createSchedulerTask(15000,
			                     boost::bind(&ServicePort::openAcceptor, boost::weak_ptr<ServicePort>(shared_from_this()), m_serverPort)));
		}
	}
}