Added disconnect functionality and removed some warnings.

This commit is contained in:
Jocke
2016-02-10 23:27:46 +01:00
parent ec54b1298d
commit eb244f87c4
9 changed files with 31 additions and 21 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ protected:
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
void parseSnapshot(Packet& packet);
void identifyPacketLoss();
bool hasServerTimedOut();
void hasServerTimedOut();
EntityID createPlayer();
void sendInputCommands();
void sendLocalPlayerTransform();
+1 -1
View File
@@ -50,7 +50,7 @@ public:
// Pops the first element as if it was a string.
std::string ReadString();
// Construct a packet
void ReconstructFromData(char* data, int SizeOfData);
void ReconstructFromData(char* data, size_t SizeOfData);
// Update size of packet variable in header
void UpdateSize();
char* ReadData(int SizeOfData);
+5 -4
View File
@@ -27,12 +27,16 @@ public:
~Server();
void Start(World* m_world, EventBroker *eventBroker) override;
void Update() override;
protected:
private:
// Network channels
TCPServer m_Reliable;
UDPServer m_Unreliable;
// dont forget to set these in the childrens receive logic
boost::asio::ip::address m_Address;
unsigned short m_Port;
// Sending messages to client logic
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
std::vector<PlayerID> m_PlayersToDisconnect;
// HACK: Fix INPUTSIZE
char readBuffer[BUFFERSIZE] = { 0 };
size_t bytesRead = 0;
@@ -88,9 +92,6 @@ protected:
bool OnEntityDeleted(const Events::EntityDeleted& e);
EventRelay<Server, Events::ComponentDeleted> m_EComponentDeleted;
bool OnComponentDeleted(const Events::ComponentDeleted& e);
private:
TCPServer m_Reliable;
UDPServer m_Unreliable;
};
#endif
+1 -1
View File
@@ -20,7 +20,7 @@ private:
boost::asio::ip::tcp::endpoint m_Endpoint;
boost::asio::io_service m_IOService;
std::unique_ptr<boost::asio::ip::tcp::socket> m_Socket;
int readBuffer(char* data);
size_t readBuffer(char* data);
PacketID m_SendPacketID = 0;
bool m_IsConnected = false;
};