2013-12-16 09:00:11 +01:00
|
|
|
|
2013-12-13 23:47:16 +01:00
|
|
|
#include "ClientObject.h"
|
2013-12-12 09:33:59 +01:00
|
|
|
#include "NetworkSession.h"
|
2013-12-12 20:32:54 +01:00
|
|
|
#include <mutex>
|
2013-12-12 09:33:59 +01:00
|
|
|
|
|
|
|
namespace DanBias
|
|
|
|
{
|
|
|
|
NetworkSession::NetworkSession()
|
|
|
|
{
|
2013-12-12 20:32:54 +01:00
|
|
|
|
2013-12-12 09:33:59 +01:00
|
|
|
}
|
|
|
|
NetworkSession::~NetworkSession()
|
|
|
|
{
|
2013-12-12 20:32:54 +01:00
|
|
|
|
2013-12-12 09:33:59 +01:00
|
|
|
}
|
|
|
|
|
2013-12-13 23:47:16 +01:00
|
|
|
void NetworkSession::AttachClient(Utility::DynamicMemory::SmartPointer<ClientObject> client)
|
2013-12-12 09:33:59 +01:00
|
|
|
{
|
2013-12-13 23:47:16 +01:00
|
|
|
for (unsigned int i = 0; i < this->clients.size(); i++)
|
|
|
|
{
|
|
|
|
if(!this->clients[i])
|
|
|
|
{
|
|
|
|
this->clients[i] = client;
|
2013-12-16 09:00:11 +01:00
|
|
|
this->clients[i]->SetPostbox(&this->box);
|
2013-12-13 23:47:16 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->clients.push_back(client);
|
2013-12-12 09:33:59 +01:00
|
|
|
}
|
2013-12-16 09:00:11 +01:00
|
|
|
|
|
|
|
void NetworkSession::DetachClient(Oyster::Network::NetworkClient* client)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < this->clients.size(); i++)
|
|
|
|
{
|
|
|
|
if(this->clients[0]->NetClient_Object()->Id() == client->Id())
|
|
|
|
this->clients[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void NetworkSession::DetachClient(ClientObject* client)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-12-12 09:33:59 +01:00
|
|
|
void NetworkSession::DetachClient(short ID)
|
|
|
|
{
|
2013-12-16 09:00:11 +01:00
|
|
|
for (unsigned int i = 0; i < this->clients.size(); i++)
|
|
|
|
{
|
|
|
|
if(this->clients[0]->NetClient_Object()->Id() == ID)
|
|
|
|
this->clients[i] = 0;
|
|
|
|
}
|
|
|
|
|
2013-12-12 09:33:59 +01:00
|
|
|
}
|
2013-12-14 22:04:42 +01:00
|
|
|
void NetworkSession::DetachClient()
|
2013-12-12 09:33:59 +01:00
|
|
|
{
|
2013-12-14 22:04:42 +01:00
|
|
|
for (unsigned int i = 0; i < this->clients.size(); i++)
|
|
|
|
{
|
|
|
|
this->clients[i] = 0;
|
|
|
|
}
|
2013-12-12 09:33:59 +01:00
|
|
|
}
|
2013-12-14 22:04:42 +01:00
|
|
|
|
2013-12-12 09:33:59 +01:00
|
|
|
void NetworkSession::Kick()
|
|
|
|
{
|
2013-12-14 22:04:42 +01:00
|
|
|
for (unsigned int i = 0; i < this->clients.size(); i++)
|
|
|
|
{
|
|
|
|
this->clients[i]->NetClient_Object()->Disconnect();
|
|
|
|
this->clients[i] = 0;
|
|
|
|
}
|
2013-12-12 09:33:59 +01:00
|
|
|
}
|
|
|
|
}//End namespace DanBias
|