GameLogic - Added Postbox system to netsession
This commit is contained in:
parent
8700824d12
commit
bf5cc69ff7
|
@ -18,7 +18,7 @@ namespace DanBias
|
|||
|
||||
void NetworkSession::AttachClient(Utility::DynamicMemory::SmartPointer<ClientObject> client)
|
||||
{
|
||||
while (!ClientListLock.try_lock()); //Possible Deadlock
|
||||
ClientListLock.lock();
|
||||
|
||||
int k = -1;
|
||||
for (unsigned int i = 0; (k == -1) && i < this->clients.size(); i++)
|
||||
|
@ -43,44 +43,67 @@ namespace DanBias
|
|||
|
||||
void NetworkSession::DetachClient(Oyster::Network::NetworkClient* client)
|
||||
{
|
||||
ClientListLock.lock();
|
||||
|
||||
for (unsigned int i = 0; i < this->clients.size(); i++)
|
||||
{
|
||||
if(this->clients[0]->NetClient_Object()->Id() == client->Id())
|
||||
this->clients[i] = 0;
|
||||
}
|
||||
|
||||
ClientListLock.unlock();
|
||||
}
|
||||
void NetworkSession::DetachClient(ClientObject* client)
|
||||
{
|
||||
ClientListLock.lock();
|
||||
|
||||
for (unsigned int i = 0; i < this->clients.size(); i++)
|
||||
{
|
||||
if(this->clients[0]->NetClient_Object()->Id() == client->NetClient_Object()->Id())
|
||||
this->clients[i] = 0;
|
||||
}
|
||||
|
||||
ClientListLock.unlock();
|
||||
}
|
||||
void NetworkSession::DetachClient(short ID)
|
||||
{
|
||||
ClientListLock.lock();
|
||||
|
||||
for (unsigned int i = 0; i < this->clients.size(); i++)
|
||||
{
|
||||
if(this->clients[0]->NetClient_Object()->Id() == ID)
|
||||
this->clients[i] = 0;
|
||||
}
|
||||
|
||||
ClientListLock.unlock();
|
||||
}
|
||||
void NetworkSession::DetachClient()
|
||||
{
|
||||
ClientListLock.lock();
|
||||
|
||||
for (unsigned int i = 0; i < this->clients.size(); i++)
|
||||
{
|
||||
this->clients[i] = 0;
|
||||
}
|
||||
|
||||
ClientListLock.unlock();
|
||||
}
|
||||
|
||||
void NetworkSession::Kick()
|
||||
{
|
||||
ClientListLock.lock();
|
||||
|
||||
for (unsigned int i = 0; i < this->clients.size(); i++)
|
||||
{
|
||||
this->clients[i]->NetClient_Object()->Disconnect();
|
||||
this->clients[i] = 0;
|
||||
}
|
||||
|
||||
ClientListLock.unlock();
|
||||
}
|
||||
|
||||
void NetworkSession::SetPostbox(Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box)
|
||||
{
|
||||
this->box = box;
|
||||
}
|
||||
}//End namespace DanBias
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#define NOMINMAX
|
||||
#include "Utilities.h"
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <PostBox\IPostBox.h>
|
||||
#include <CustomNetProtocol.h>
|
||||
#include <NetworkClient.h>
|
||||
#include <vector>
|
||||
|
@ -40,11 +40,11 @@ namespace DanBias
|
|||
void Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
|
||||
|
||||
//TODO: Do more lobby features
|
||||
//virtual void
|
||||
void SetPostbox(Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box);
|
||||
|
||||
protected:
|
||||
std::vector<Utility::DynamicMemory::SmartPointer<ClientObject>> clients;
|
||||
Oyster::PostBox<DanBias::NetworkSession::NetEvent> box;
|
||||
Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box;
|
||||
};
|
||||
}//End namespace DanBias
|
||||
#endif // !DANBIASSERVER_NETWORK_SESSION_H
|
||||
|
|
Loading…
Reference in New Issue