Exemple #1
0
	void NetGameServer::listen_thread_main()
	{
		while (true)
		{
			std::unique_lock<std::mutex> lock(impl->mutex);
			if (impl->stop_flag)
				break;

			NetworkEvent *events[] = { impl->tcp_listen.get() };
			impl->worker_event.wait(lock, 1, events);

			SocketName peer_endpoint;
			TCPConnection connection = impl->tcp_listen->accept(peer_endpoint);
			if (!connection.is_null())
			{
				std::unique_ptr<NetGameConnection> game_connection(new NetGameConnection(this, connection));
				impl->connections.push_back(game_connection.release());
			}
		}
	}