Danbias/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp

54 lines
1.2 KiB
C++
Raw Normal View History

2013-12-12 09:33:59 +01:00
#include "ClientObject.h"
using namespace DanBias;
2013-12-17 10:25:34 +01:00
ClientObject::ClientObject(Oyster::Network::NetworkClient* client)
2013-12-12 09:33:59 +01:00
{
2013-12-13 23:47:16 +01:00
this->client = client;
2013-12-17 10:25:34 +01:00
this->client->SetRecieverObject(this, Oyster::Network::NetworkProtocolCallbackType_Object);
2013-12-13 23:47:16 +01:00
this->box = 0;
2013-12-12 09:33:59 +01:00
}
ClientObject::~ClientObject()
{
2013-12-17 10:25:34 +01:00
this->client->Disconnect();
2013-12-12 09:33:59 +01:00
}
2013-12-19 12:32:23 +01:00
void ClientObject::SetProtocolCallback(Oyster::Network::ProtocolRecieverObject* object)
{
2013-12-20 09:42:02 +01:00
this->GetClient()->SetRecieverObject(object, Oyster::Network::NetworkProtocolCallbackType_Object);
2013-12-19 12:32:23 +01:00
}
2013-12-18 08:44:10 +01:00
void ClientObject::SetPostbox(Oyster::IPostBox<NetworkSession::NetEvent>* box)
2013-12-13 23:47:16 +01:00
{
this->box = box;
}
2013-12-20 09:42:02 +01:00
GameLogic::Player* ClientObject::GetPlayer()
{
2013-12-20 09:42:02 +01:00
return this->player.Get();
}
2013-12-20 09:42:02 +01:00
Oyster::Network::NetworkClient* ClientObject::GetClient()
{
2013-12-20 09:42:02 +01:00
return this->client.Get();
}
2013-12-19 15:35:49 +01:00
void ClientObject::CreatePlayer()
{
2013-12-20 09:42:02 +01:00
if(this->player) return;
2013-12-19 15:35:49 +01:00
2013-12-20 09:42:02 +01:00
this->player = new GameLogic::Player();
}
void ClientObject::ErasePlayer()
{
while(this->player.Release());
2013-12-19 15:35:49 +01:00
}
2013-12-13 23:47:16 +01:00
void ClientObject::ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol)
{
if(!this->box) return;
2013-12-16 09:09:54 +01:00
NetworkSession::NetEvent _event;
2013-12-13 23:47:16 +01:00
_event.protocol = protocol;
_event.reciever = this;
this->box->Post(_event);
}
2013-12-12 09:33:59 +01:00