Danbias/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h

58 lines
2.0 KiB
C
Raw Normal View History

2013-12-16 09:00:11 +01:00
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
2013-12-12 09:33:59 +01:00
#ifndef DANBIASSERVER_NETWORK_SESSION_H
#define DANBIASSERVER_NETWORK_SESSION_H
#pragma warning(disable: 4150)
#define NOMINMAX
2013-12-19 12:32:23 +01:00
#include <Utilities.h>
#include <DynamicArray.h>
#include <PostBox\IPostBox.h>
2013-12-16 09:00:11 +01:00
#include <CustomNetProtocol.h>
#include <NetworkClient.h>
2013-12-12 09:33:59 +01:00
#include <vector>
2013-12-12 09:33:59 +01:00
namespace DanBias
{
2013-12-13 23:47:16 +01:00
class ClientObject;
2013-12-12 09:33:59 +01:00
class NetworkSession
{
2013-12-13 23:47:16 +01:00
public:
2013-12-16 09:00:11 +01:00
struct NetEvent
2013-12-13 23:47:16 +01:00
{
ClientObject* reciever;
Oyster::Network::CustomNetProtocol protocol;
};
2013-12-12 09:33:59 +01:00
public:
NetworkSession();
NetworkSession(const NetworkSession& orig);
const NetworkSession& operator=(const NetworkSession& orig);
virtual~NetworkSession();
2013-12-12 09:33:59 +01:00
virtual void AttachClient(Utility::DynamicMemory::SmartPointer<ClientObject> client, Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box = 0);
2013-12-12 09:33:59 +01:00
virtual Utility::DynamicMemory::SmartPointer<ClientObject> DetachClient(Oyster::Network::NetworkClient* client);
virtual Utility::DynamicMemory::SmartPointer<ClientObject> DetachClient(ClientObject* client);
virtual Utility::DynamicMemory::SmartPointer<ClientObject> DetachClient(short ID);
2013-12-12 09:33:59 +01:00
virtual void Send(Oyster::Network::CustomNetProtocol& protocol);
virtual void Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
2013-12-12 09:33:59 +01:00
//TODO: Do more lobby features
virtual void SetPostbox(Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box);
virtual void CloseSession(NetworkSession* clientDestination); //<! Closes the session and sends the clients to given sesison. If session is null, clients is kicked from server.
2013-12-12 09:33:59 +01:00
2013-12-19 12:32:23 +01:00
Utility::DynamicMemory::SmartPointer<ClientObject> FindClient(int ID);
Utility::DynamicMemory::SmartPointer<ClientObject> FindClient(ClientObject& obj);
2013-12-12 09:33:59 +01:00
protected:
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<ClientObject>> clients;
2013-12-12 09:33:59 +01:00
};
}//End namespace DanBias
#endif // !DANBIASSERVER_NETWORK_SESSION_H