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
2013-12-18 13:07:10 +01:00
# pragma warning(disable: 4150)
2013-12-14 22:04:42 +01:00
# define NOMINMAX
2013-12-12 09:33:59 +01:00
# include "Utilities.h"
2013-12-18 13:07:10 +01:00
# include <DynamicArray.h>
2013-12-18 08:37:45 +01:00
# 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-18 13:07:10 +01:00
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 ( ) ;
2013-12-18 13:07:10 +01:00
NetworkSession ( const NetworkSession & orig ) ;
const NetworkSession & operator = ( const NetworkSession & orig ) ;
virtual ~ NetworkSession ( ) ;
2013-12-12 09:33:59 +01:00
2013-12-18 13:07:10 +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
2013-12-18 13:07:10 +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
2013-12-18 13:07:10 +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
2013-12-18 13:07:10 +01:00
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
protected :
2013-12-18 13:07:10 +01:00
Utility : : DynamicMemory : : DynamicArray < Utility : : DynamicMemory : : SmartPointer < ClientObject > > clients ;
2013-12-12 09:33:59 +01:00
} ;
} //End namespace DanBias
# endif // !DANBIASSERVER_NETWORK_SESSION_H