2014-01-07 10:26:09 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
#include "MainLobby.h"
|
|
|
|
#include "LobbyClient.h"
|
|
|
|
#include <PlayerProtocols.h>
|
|
|
|
#include <PostBox\PostBox.h>
|
|
|
|
|
|
|
|
using namespace Utility::DynamicMemory;
|
|
|
|
using namespace Oyster::Network;
|
|
|
|
using namespace Oyster;
|
|
|
|
|
|
|
|
namespace DanBias
|
|
|
|
{
|
|
|
|
MainLobby::MainLobby()
|
|
|
|
:gameLobby(5)
|
|
|
|
{
|
|
|
|
this->box = new PostBox<DanBias::NetworkSession::NetEvent>();
|
|
|
|
}
|
|
|
|
MainLobby::~MainLobby()
|
|
|
|
{
|
2014-01-09 14:18:01 +01:00
|
|
|
|
2014-01-07 10:26:09 +01:00
|
|
|
}
|
|
|
|
void MainLobby::Release()
|
|
|
|
{
|
2014-01-09 14:18:01 +01:00
|
|
|
delete this->box;
|
|
|
|
this->box = 0;
|
2014-01-07 10:26:09 +01:00
|
|
|
this->CloseSession(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainLobby::Frame()
|
|
|
|
{
|
|
|
|
ParseEvents();
|
|
|
|
}
|
|
|
|
IPostBox<NetworkSession::NetEvent>* MainLobby::GetPostbox()
|
|
|
|
{
|
|
|
|
return this->box;
|
|
|
|
}
|
2014-01-22 15:22:52 +01:00
|
|
|
void MainLobby::SetRefreshFrequency(float delta)
|
|
|
|
{
|
|
|
|
this->refreshFrequency = delta;
|
|
|
|
}
|
2014-01-07 10:26:09 +01:00
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
float MainLobby::GetRefreshFrequency() const
|
|
|
|
{
|
|
|
|
return this->refreshFrequency;
|
|
|
|
}
|
2014-01-07 10:26:09 +01:00
|
|
|
//////// Private
|
|
|
|
void MainLobby::ParseEvents()
|
|
|
|
{
|
|
|
|
if(this->box && !this->box->IsEmpty())
|
|
|
|
{
|
|
|
|
NetEvent &e = this->box->Fetch();
|
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
short type = e.protocol[0].value.netShort;
|
2014-01-07 10:26:09 +01:00
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
if(ProtocolIsLobby(type)) ParseLobbyProtocol(e.protocol, e.sender);
|
|
|
|
else if(ProtocolIsGeneral(type)) ParseGeneralProtocol(e.protocol, e.sender);
|
2014-01-07 10:26:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}//End namespace DanBias
|