Added an event to search for servers.

Client now broadcasts a serverlistrequest.
An active server will then answer the request and send info about the server.
The client saves this data to a list and presents it to the user.
This commit is contained in:
stiffly
2016-02-19 15:38:09 +01:00
parent 46987beefb
commit 2f259c3773
12 changed files with 178 additions and 51 deletions
+22
View File
@@ -36,7 +36,29 @@ void UDPServer::Send(Packet & packet)
0);
}
// Broadcasting respond specific logic
void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint)
{
m_Socket->send_to(
boost::asio::buffer(
packet.Data(),
packet.Size()),
endpoint,
0);
}
// Broadcasting
void UDPServer::Broadcast(Packet & packet, int port)
{
m_Socket->set_option(boost::asio::socket_base::broadcast(true));
m_Socket->send_to(
boost::asio::buffer(
packet.Data(),
packet.Size()),
boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4().broadcast(),port),
0);
m_Socket->set_option(boost::asio::socket_base::broadcast(false));
}
void UDPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition)
{