2014-01-28 09:00:02 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
#include "..\GameLobby.h"
|
|
|
|
#include <PlayerProtocols.h>
|
|
|
|
#include <PostBox\PostBox.h>
|
2014-01-29 15:01:14 +01:00
|
|
|
#include <Protocols.h>
|
2014-01-28 09:00:02 +01:00
|
|
|
|
|
|
|
using namespace Utility::DynamicMemory;
|
|
|
|
using namespace Oyster::Network;
|
|
|
|
using namespace Oyster;
|
|
|
|
|
|
|
|
namespace DanBias
|
|
|
|
{
|
|
|
|
GameLobby::GameLobby()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
GameLobby::~GameLobby()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void GameLobby::Release()
|
2014-01-29 10:18:01 +01:00
|
|
|
{
|
|
|
|
NetworkSession::CloseSession(true);
|
2014-01-28 09:00:02 +01:00
|
|
|
}
|
|
|
|
|
2014-01-29 10:18:01 +01:00
|
|
|
void GameLobby::Update()
|
2014-01-28 09:00:02 +01:00
|
|
|
{
|
2014-01-29 15:01:14 +01:00
|
|
|
if(GetAsyncKeyState(VK_DOWN))
|
|
|
|
this->Send(*GameLogic::Protocol_General_Status().GetProtocol());
|
|
|
|
|
2014-01-29 10:18:01 +01:00
|
|
|
this->ProcessClients();
|
2014-01-28 09:00:02 +01:00
|
|
|
}
|
2014-01-29 10:18:01 +01:00
|
|
|
GameLobby::operator bool()
|
2014-01-28 09:00:02 +01:00
|
|
|
{
|
2014-01-29 10:18:01 +01:00
|
|
|
return true;
|
2014-01-28 09:00:02 +01:00
|
|
|
}
|
|
|
|
|
2014-01-29 10:18:01 +01:00
|
|
|
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
|
|
|
{
|
|
|
|
switch (e.args.type)
|
|
|
|
{
|
|
|
|
case NetworkClient::ClientEventArgs::EventType_Disconnect:
|
|
|
|
break;
|
|
|
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
|
|
|
|
break;
|
|
|
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
2014-01-29 15:01:14 +01:00
|
|
|
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
|
|
|
e.sender->Disconnect();
|
2014-01-29 10:18:01 +01:00
|
|
|
break;
|
|
|
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
2014-01-29 15:01:14 +01:00
|
|
|
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
2014-01-29 10:18:01 +01:00
|
|
|
this->ParseProtocol(e.args.data.protocol, e.sender);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
2014-01-28 09:00:02 +01:00
|
|
|
{
|
2014-01-29 15:01:14 +01:00
|
|
|
printf("New client(%i) connected - %s \n", client->GetID(), client->GetIpAddress().c_str());
|
|
|
|
Attach(client);
|
2014-01-28 09:00:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}//End namespace DanBias
|