2014-01-28 09:00:02 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef DANBIASSERVER_CLIENT_OBJECT_H
|
|
|
|
#define DANBIASSERVER_CLIENT_OBJECT_H
|
|
|
|
|
|
|
|
#include <NetworkClient.h>
|
2014-02-18 11:34:24 +01:00
|
|
|
#include <NetworkSession.h>
|
2014-01-28 09:00:02 +01:00
|
|
|
#include <PostBox\PostBox.h>
|
|
|
|
#include <GameAPI.h>
|
2014-01-29 10:18:01 +01:00
|
|
|
#include <Utilities.h>
|
2014-01-28 09:00:02 +01:00
|
|
|
|
|
|
|
namespace DanBias
|
|
|
|
{
|
2014-01-29 10:18:01 +01:00
|
|
|
/**
|
|
|
|
* Container to keep logic player and network client together as a unit.
|
|
|
|
*/
|
2014-01-28 09:00:02 +01:00
|
|
|
class GameClient
|
|
|
|
{
|
2014-02-18 16:38:08 +01:00
|
|
|
public:
|
|
|
|
enum ClientState
|
|
|
|
{
|
|
|
|
ClientState_CreatingGame,
|
|
|
|
ClientState_Ready,
|
2014-02-20 08:33:07 +01:00
|
|
|
ClientState_Invalid,
|
2014-02-18 16:38:08 +01:00
|
|
|
};
|
|
|
|
|
2014-01-28 09:00:02 +01:00
|
|
|
public:
|
2014-02-18 11:34:24 +01:00
|
|
|
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient);
|
2014-01-28 09:00:02 +01:00
|
|
|
virtual~GameClient();
|
|
|
|
|
2014-02-18 08:55:38 +01:00
|
|
|
inline bool operator==(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
|
2014-02-18 11:34:24 +01:00
|
|
|
inline bool operator==(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
|
2014-01-31 08:41:08 +01:00
|
|
|
|
2014-02-18 11:34:24 +01:00
|
|
|
inline bool Equals(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
|
|
|
|
inline bool Equals(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
|
|
|
|
|
|
|
|
inline float GetSinceLastResponse() const { return this->secondsSinceLastResponse; }
|
|
|
|
inline std::wstring GetAlias() const { return this->alias; }
|
|
|
|
inline std::wstring GetCharacter() const { return this->character; }
|
|
|
|
inline bool IsReady() const { return this->isReady; }
|
|
|
|
inline GameLogic::IPlayerData* GetPlayer() const { return this->player; }
|
|
|
|
Oyster::Network::NetClient GetClient() const { return this->client; }
|
2014-02-18 16:38:08 +01:00
|
|
|
ClientState GetState() const { return this->state; }
|
2014-02-20 08:33:07 +01:00
|
|
|
int GetFailedProtocolCount() const { return this->failedPackagesCount; }
|
2014-02-18 08:55:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
void SetPlayer(GameLogic::IPlayerData* player);
|
2014-02-04 16:07:10 +01:00
|
|
|
void SetReadyState(bool isReady);
|
2014-02-18 08:55:38 +01:00
|
|
|
void SetAlias(std::wstring alias);
|
|
|
|
void SetCharacter(std::wstring character);
|
2014-02-04 16:07:10 +01:00
|
|
|
void SetSinceLastResponse(float seconds);
|
2014-02-18 16:38:08 +01:00
|
|
|
void SetState(ClientState state);
|
2014-02-04 16:07:10 +01:00
|
|
|
|
2014-02-18 11:34:24 +01:00
|
|
|
GameLogic::IPlayerData* ReleasePlayer();
|
|
|
|
Oyster::Network::NetClient ReleaseClient();
|
|
|
|
|
2014-02-20 16:52:36 +01:00
|
|
|
bool IsInvalid();
|
2014-02-20 08:33:07 +01:00
|
|
|
void Invalidate();
|
|
|
|
int IncrementFailedProtocol();
|
|
|
|
void ResetFailedProtocolCount();
|
|
|
|
|
2014-02-18 11:34:24 +01:00
|
|
|
//NetworkSpecific
|
|
|
|
void SetOwner(Oyster::Network::NetworkSession* owner);
|
|
|
|
void UpdateClient();
|
|
|
|
|
2014-01-28 09:00:02 +01:00
|
|
|
private:
|
|
|
|
GameLogic::IPlayerData* player;
|
2014-02-18 16:38:08 +01:00
|
|
|
Oyster::Network::NetClient client;
|
2014-02-18 08:55:38 +01:00
|
|
|
|
2014-02-04 16:07:10 +01:00
|
|
|
bool isReady;
|
2014-02-20 08:33:07 +01:00
|
|
|
bool isInvalid;
|
2014-02-04 16:07:10 +01:00
|
|
|
float secondsSinceLastResponse;
|
2014-02-20 08:33:07 +01:00
|
|
|
int failedPackagesCount;
|
2014-01-28 09:00:02 +01:00
|
|
|
|
2014-02-18 08:55:38 +01:00
|
|
|
std::wstring alias;
|
|
|
|
std::wstring character;
|
2014-02-18 16:38:08 +01:00
|
|
|
|
|
|
|
ClientState state;
|
2014-02-18 08:55:38 +01:00
|
|
|
};
|
2014-01-28 09:00:02 +01:00
|
|
|
}//End namespace DanBias
|
2014-02-18 11:34:24 +01:00
|
|
|
|
|
|
|
typedef Utility::DynamicMemory::SmartPointer<DanBias::GameClient> gClient;
|
|
|
|
|
2014-01-28 09:00:02 +01:00
|
|
|
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|