Danbias/Code/Network/NetworkAPI/NetworkServer.h

101 lines
2.2 KiB
C
Raw Normal View History

2013-12-10 08:32:08 +01:00
#ifndef NETWORK_API_NETWORK_SERVER_H
#define NETWORK_API_NETWORK_SERVER_H
2014-01-28 09:00:02 +01:00
//////////////////////////////////////
// Created by Pontus Fransson 2013 //
// Modified by Dennis Andersen 2014 //
//////////////////////////////////////
2013-12-10 08:32:08 +01:00
2014-01-28 09:00:02 +01:00
#include "NetworkAPI_Preprocessor.h"
#include "NetworkClient.h"
2014-01-28 09:00:02 +01:00
#include "NetworkSession.h"
2013-12-13 23:47:16 +01:00
#include <vld.h>
2013-12-10 08:32:08 +01:00
namespace Oyster
{
namespace Network
{
extern "C"
2013-12-10 08:32:08 +01:00
{
2014-01-28 09:00:02 +01:00
class NET_API_EXPORT NetworkServer
2013-12-10 08:32:08 +01:00
{
public:
2014-01-28 09:00:02 +01:00
enum ServerReturnCode
2013-12-10 08:32:08 +01:00
{
2014-01-28 09:00:02 +01:00
ServerReturnCode_Error,
ServerReturnCode_Sucess
};
2013-12-10 08:32:08 +01:00
2014-01-28 09:00:02 +01:00
public:
NetworkServer();
2014-01-28 09:00:02 +01:00
NetworkServer(const NetworkServer&);
const NetworkServer& operator=(const NetworkServer&);
virtual ~NetworkServer();
2013-12-10 08:32:08 +01:00
2014-01-28 09:00:02 +01:00
/** Creates a server that clients can connect to
* @param port The port the server will be listening for clients.
* @param mainSession The main session the server will send connected clients to.
* @return The server returncode
*/
ServerReturnCode Init(const int& port, NetworkSession const* mainSession);
/** Starts the server allowing clients to connect
* @return The server returncode
*/
ServerReturnCode Start();
2014-01-30 00:19:00 +01:00
/** Parses asynchronous connected clients.
*/
int Update();
2014-01-28 09:00:02 +01:00
/**
*
*/
void Stop();
2014-01-28 09:00:02 +01:00
/** Shutdown the server and return all resources.
*/
void Shutdown();
2013-12-10 08:32:08 +01:00
2014-01-28 09:00:02 +01:00
/** Set the main session connected clients will enter when connected to server.
* @param mainSession The session to connect as main server session.
*/
void SetSession(NetworkSession const* mainSession);
/** Get the main session connected with the server
* @return Returns the main session
*/
NetworkSession const* GetMainSession();
/** Sets the main session to NULL and returns it
* @return Returns the main session
*/
2014-01-29 10:18:01 +01:00
NetworkSession const* ReleaseMainSession();
2014-01-28 09:00:02 +01:00
/**
*
*/
bool IsRunning() const;
2013-12-10 08:32:08 +01:00
2014-01-29 10:18:01 +01:00
/**
*
*/
std::string GetLanAddress();
2014-01-28 09:00:02 +01:00
/** Returns the port the server is listening on.
* @return Returns the port the server has been initiated with.
2014-01-30 00:19:00 +01:00
*/
int NetworkServer::GetPort();
private:
struct PrivateData;
PrivateData* privateData;
2013-12-10 08:32:08 +01:00
};
2013-12-10 08:32:08 +01:00
}
}
}
#endif