Serverlist fix.
This commit is contained in:
@@ -203,6 +203,8 @@ void Client::parseServerlist(Packet& packet)
|
|||||||
std::string serverName = packet.ReadString();
|
std::string serverName = packet.ReadString();
|
||||||
int playersConnected = packet.ReadPrimitive<int>();
|
int playersConnected = packet.ReadPrimitive<int>();
|
||||||
//TODO: This should not happen when a client is connected to a server
|
//TODO: This should not happen when a client is connected to a server
|
||||||
|
LOG_INFO("Parsing a server list!");
|
||||||
|
|
||||||
m_Serverlist.push_back({ address, port, serverName, playersConnected });
|
m_Serverlist.push_back({ address, port, serverName, playersConnected });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ void Server::parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint)
|
|||||||
packet.WritePrimitive<int>(m_ConnectedPlayers.size());
|
packet.WritePrimitive<int>(m_ConnectedPlayers.size());
|
||||||
//PlayerDefinition pDef;
|
//PlayerDefinition pDef;
|
||||||
//pDef.Endpoint = boost::asio::ip::udp::endpoint(endpoint.address(), 13);
|
//pDef.Endpoint = boost::asio::ip::udp::endpoint(endpoint.address(), 13);
|
||||||
|
LOG_INFO("Parsing a server list request!");
|
||||||
m_ServerlistRequest.Send(packet/*, endpoint*/);
|
m_ServerlistRequest.Send(packet/*, endpoint*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ void UDPClient::Send(Packet& packet)
|
|||||||
|
|
||||||
void UDPClient::Broadcast(Packet& packet, int port)
|
void UDPClient::Broadcast(Packet& packet, int port)
|
||||||
{
|
{
|
||||||
|
packet.UpdateSize();
|
||||||
m_Socket->set_option(boost::asio::socket_base::broadcast(true));
|
m_Socket->set_option(boost::asio::socket_base::broadcast(true));
|
||||||
m_Socket->send_to(boost::asio::buffer(
|
m_Socket->send_to(boost::asio::buffer(
|
||||||
packet.Data(),
|
packet.Data(),
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ void UDPServer::Send(Packet & packet)
|
|||||||
// Broadcasting respond specific logic
|
// Broadcasting respond specific logic
|
||||||
void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint)
|
void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint)
|
||||||
{
|
{
|
||||||
|
packet.UpdateSize();
|
||||||
m_Socket->send_to(
|
m_Socket->send_to(
|
||||||
boost::asio::buffer(
|
boost::asio::buffer(
|
||||||
packet.Data(),
|
packet.Data(),
|
||||||
@@ -52,6 +53,7 @@ void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint)
|
|||||||
// Broadcasting
|
// Broadcasting
|
||||||
void UDPServer::Broadcast(Packet & packet, int port)
|
void UDPServer::Broadcast(Packet & packet, int port)
|
||||||
{
|
{
|
||||||
|
packet.UpdateSize();
|
||||||
m_Socket->set_option(boost::asio::socket_base::broadcast(true));
|
m_Socket->set_option(boost::asio::socket_base::broadcast(true));
|
||||||
m_Socket->send_to(
|
m_Socket->send_to(
|
||||||
boost::asio::buffer(
|
boost::asio::buffer(
|
||||||
@@ -68,6 +70,7 @@ void UDPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition)
|
|||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
packet.ReconstructFromData(m_ReadBuffer, bytesRead);
|
packet.ReconstructFromData(m_ReadBuffer, bytesRead);
|
||||||
}
|
}
|
||||||
|
LOG_INFO("Received server list msg");
|
||||||
playerDefinition.Endpoint = m_ReceiverEndpoint;
|
playerDefinition.Endpoint = m_ReceiverEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +93,7 @@ int UDPServer::readBuffer()
|
|||||||
if (!m_Socket) {
|
if (!m_Socket) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int addasdasd = m_Socket->available();
|
||||||
boost::system::error_code error;
|
boost::system::error_code error;
|
||||||
// Read size of packet
|
// Read size of packet
|
||||||
m_Socket->receive_from(boost
|
m_Socket->receive_from(boost
|
||||||
|
|||||||
Reference in New Issue
Block a user