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 993d804cef
12 changed files with 178 additions and 51 deletions
+2 -4
View File
@@ -33,7 +33,7 @@ private:
// Network channels
TCPServer m_Reliable;
UDPServer m_Unreliable;
UDPClient m_Heartbeat;
UDPServer m_ServerlistRequest;
// dont forget to set these in the childrens receive logic
boost::asio::ip::address m_Address;
int m_Port = 27666;
@@ -46,13 +46,11 @@ private:
// time for previouse message
std::clock_t previousePingMessage = std::clock();
std::clock_t previousSnapshotMessage = std::clock();
std::clock_t previousHeartbeat = std::clock();
std::clock_t timOutTimer = std::clock();
// How often we send messages (milliseconds)
float pingIntervalMs;
float snapshotInterval;
float heartbeatInterval = 5000;
int checkTimeOutInterval = 100;
int m_NextPlayerID = 0;
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
@@ -71,7 +69,6 @@ private:
void addChildrenToPacket(Packet& packet, EntityID entityID);
void addInputCommandsToPacket(Packet& packet);
void sendPing();
void sendHeartBeat();
void checkForTimeOuts();
void disconnect(PlayerID playerID);
void parseMessageType(Packet& packet);
@@ -86,6 +83,7 @@ private:
void parseUDPConnect(Packet & packet);
void parseTCPConnect(Packet & packet);
void parseDisconnect();
void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint);
bool shouldSendToClient(EntityWrapper childEntity);
// Debug event