Network not longer threaded

This commit is contained in:
stiffly
2015-12-18 12:00:14 +01:00
parent 6d649e4d35
commit a858dab8b6
6 changed files with 90 additions and 102 deletions
+7 -3
View File
@@ -30,6 +30,12 @@ private:
boost::asio::io_service m_IOService;
boost::asio::ip::udp::socket m_Socket;
// Sending message to server logic
int bytesRead = -1;
char readBuf[1024] = { 0 };
int snapshotInterval = 33;
std::clock_t previousSnapshotMessage = std::clock();
// Packet loss logic
unsigned int m_PacketID = 0;
unsigned int m_PreviousPacketID = 0;
@@ -37,8 +43,6 @@ private:
// Game logic
World* m_World;
std::vector<unsigned int> m_PlayersToCreate;
glm::vec2 m_PlayerPositions[MAXCONNECTIONS];
std::string m_PlayerName;
int m_PlayerID = -1;
@@ -67,9 +71,9 @@ private:
void parsePing();
void parseServerPing();
void parseSnapshot(Packet& packet);
void createNewPlayer(int i);
void identifyPacketLoss();
bool isConnected();
EntityID createPlayer();
// Events
EventBroker* m_EventBroker;
+13
View File
@@ -29,6 +29,18 @@ private:
boost::asio::ip::udp::socket m_Socket;
PlayerDefinition m_PlayerDefinitions[MAXCONNECTIONS];
// Sending messages to client logic
char readBuffer[1024] = { 0 };
int bytesRead = 0;
// time for previouse message
std::clock_t previousePingMessage = std::clock();
std::clock_t previousSnapshotMessage = std::clock();
std::clock_t timOutTimer = std::clock();
// How often we send messages (milliseconds)
int intervalMs = 1000;
int snapshotInterval = 50;
int checkTimeOutInterval = 100;
//Timers
std::clock_t m_StartPingTime;
std::clock_t m_StopTimes[8];
@@ -67,6 +79,7 @@ private:
void parseServerPing();
void parseSnapshot(Packet& packet);
void identifyPacketLoss();
EntityID createPlayer();
};
#endif