From 092f83a084c2b5632cbe681f1d8971e0639e5328 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 12 Dec 2013 15:33:11 +0100 Subject: [PATCH] Network - Id on client and == operator. --- Code/Network/NetworkAPI/NetworkClient.cpp | 15 +++++++++++++-- Code/Network/NetworkAPI/NetworkClient.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 94077d52..590a6aa2 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -52,9 +52,15 @@ struct NetworkClient::PrivateData : public IThreadObject std::mutex postBoxMutex; Translator translator; + + //ID + static unsigned int currID; + const unsigned int ID; }; -NetworkClient::PrivateData::PrivateData() +unsigned int NetworkClient::PrivateData::currID = 0; + +NetworkClient::PrivateData::PrivateData() : ID(currID++) { InitWinSock(); @@ -67,7 +73,7 @@ NetworkClient::PrivateData::PrivateData() Start(); } -NetworkClient::PrivateData::PrivateData(unsigned int socket) +NetworkClient::PrivateData::PrivateData(unsigned int socket) : ID(currID++) { InitWinSock(); @@ -259,4 +265,9 @@ void NetworkClient::SetRecieverObject(RecieverObject recvObj, NetworkProtocolCal privateData->recvObj = SmartPointer(&recvObj); privateData->callbackType = type; privateData->recvObjMutex.unlock(); +} + +bool NetworkClient::operator ==(const NetworkClient& obj) +{ + return (this->privateData->ID == obj.privateData->ID); } \ No newline at end of file diff --git a/Code/Network/NetworkAPI/NetworkClient.h b/Code/Network/NetworkAPI/NetworkClient.h index b3c30419..2683b582 100644 --- a/Code/Network/NetworkAPI/NetworkClient.h +++ b/Code/Network/NetworkAPI/NetworkClient.h @@ -41,6 +41,8 @@ namespace Oyster void SetRecieverObject(RecieverObject recvObj, NetworkProtocolCallbackType type); + bool operator ==(const NetworkClient& obj); + private: struct PrivateData; PrivateData* privateData;