Danbias/Code/Network/NetworkAPI/NetworkSession.h

97 lines
2.3 KiB
C
Raw Normal View History

2014-01-28 09:00:02 +01:00
/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef NETWORK_API_NETWORK_SESSION_H
#define NETWORK_API_NETWORK_SESSION_H
//warning C4150: deletion of pointer to incomplete type, no destructor called
#pragma warning(disable : 4150)
#include "NetworkAPI_Preprocessor.h"
#include "NetworkServerEventStruct.h"
#include "NetworkClient.h"
2014-01-29 10:18:01 +01:00
#include "Utilities.h"
2014-01-28 09:00:02 +01:00
namespace Oyster
{
namespace Network
{
2014-01-29 10:18:01 +01:00
typedef Utility::DynamicMemory::SmartPointer<NetworkClient> NetClient;
2014-01-28 09:00:02 +01:00
class NET_API_EXPORT NetworkSession
{
public:
NetworkSession();
NetworkSession(const NetworkSession& orig);
const NetworkSession& operator=(const NetworkSession& orig);
virtual~NetworkSession();
/** Parse session events such as protocols recieved etc.
*/
void ProcessClients();
/**
*
*/
2014-01-29 10:18:01 +01:00
virtual bool Attach(NetClient client);
2014-01-28 09:00:02 +01:00
2014-01-29 10:18:01 +01:00
/**
* Detaches all clients and sends them to owner.
* If no owner is set the clients is disconnected.
*/
virtual void Detach();
2014-01-28 09:00:02 +01:00
/**
*
*/
2014-01-29 10:18:01 +01:00
virtual NetClient Detach(const NetworkClient* client);
2014-01-28 09:00:02 +01:00
/**
*
*/
2014-01-29 10:18:01 +01:00
virtual NetClient Detach(short ID);
2014-01-28 09:00:02 +01:00
/** Send a message to all clients in this session
* @param message The message
*/
2014-01-29 10:18:01 +01:00
virtual bool Send(Oyster::Network::CustomNetProtocol& message);
2014-01-28 09:00:02 +01:00
/** Send a message to a specific client in this session
* @param message The message
*/
2014-01-29 10:18:01 +01:00
virtual bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
2014-01-28 09:00:02 +01:00
/**
*
*/
2014-01-29 10:18:01 +01:00
virtual void CloseSession( bool dissconnectClients = false );
2014-01-28 09:00:02 +01:00
/**
* Set the owner that clients will be returned to.
* @param owner If owner is NULL, clients will be disconnected when session is over.
*/
2014-01-29 10:18:01 +01:00
virtual void SetOwner(NetworkSession* owner);
/** Get the number of clients active in this session
* @return The client count
*/
int GetClientCount() const;
2014-01-28 09:00:02 +01:00
/**
*
*/
2014-01-29 10:18:01 +01:00
virtual void ClientConnectedEvent(NetClient client);
2014-01-28 09:00:02 +01:00
/**
*
*/
2014-01-29 10:18:01 +01:00
virtual void ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e) = 0;
2014-01-28 09:00:02 +01:00
private:
struct PrivateSessionData;
PrivateSessionData* data;
};
}
}//End namespace DanBias
#endif // !DANBIASSERVER_NETWORK_SESSION_H