TDME2 1.9.121
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Server< CLIENT, GROUP > Class Template Reference

Base class for network servers. More...

#include <tdme/network/udpserver/Server.h>

Collaboration diagram for Server< CLIENT, GROUP >:
Collaboration graph

Public Types

typedef std::set< std::string > ClientKeySet
 
typedef std::set< std::string > GroupKeySet
 

Public Member Functions

 Server (const std::string &name, const std::string &host, const unsigned int port, const unsigned int maxCCU)
 
void setIOThreadCount (const unsigned int ioThreadCount)
 Sets up the numbers of threads to handle IO and framing. More...
 
void setWorkerThreadCount (const unsigned int workerThreadCount)
 Sets up the number of workers that handle requests in thread pool. More...
 
void setThreadPoolMaxElements (const unsigned int maxElements)
 Sets up max number of elements in worker thread pool queue. More...
 
virtual ~Server ()
 destructor More...
 
ClientKeySet getClientKeySet ()
 get a copy of current client keys More...
 
CLIENT * getClientByKey (const std::string &clientKey)
 retrieve a client by key, the client reference is acquired, must be released after usage More...
 
ClientKeySet getGroupKeySet ()
 get a copy of current group keys More...
 
GROUP * getGroupByKey (const std::string &groupKey)
 retrieve a group by key, the group reference is acquired, must be released after usage More...
 

Protected Types

typedef std::map< const std::string, CLIENT * > ClientKeyMap
 
typedef std::map< const std::string, CLIENT * > GroupKeyMap
 
typedef std::set< CLIENT * > ClientSet
 

Protected Member Functions

bool setClientKey (CLIENT *client, const std::string &clientKey)
 sets a client identification key More...
 
void closeClient (CLIENT *client)
 closes a client connection More...
 
bool setGroupKey (GROUP *group, const std::string &groupKey)
 sets a group identification key More...
 
void closeGroup (GROUP *group)
 closes a group connection More...
 

Protected Attributes

std::string name
 
std::string host
 
unsigned int port
 
unsigned int maxCCU
 
BarrierstartUpBarrier
 
ClientKeyMap clientKeyMap
 
ClientKeySet clientKeySet
 
ReadWriteLock clientKeyListsReadWriteLock
 
GroupKeyMap groupKeyMap
 
GroupKeySet groupKeySet
 
ReadWriteLock groupKeyListsReadWriteLock
 
unsigned int ioThreadCount
 
unsigned int workerThreadPoolCount
 
unsigned int workerThreadPoolMaxElements
 

Detailed Description

template<typename CLIENT, typename GROUP>
class tdme::network::udpserver::Server< CLIENT, GROUP >

Base class for network servers.

Author
Andreas Drewke

Definition at line 26 of file Server.h.

Member Typedef Documentation

◆ ClientKeyMap

typedef std::map<const std::string, CLIENT*> ClientKeyMap
protected

Definition at line 145 of file Server.h.

◆ ClientKeySet

typedef std::set<std::string> ClientKeySet

Definition at line 28 of file Server.h.

◆ ClientSet

typedef std::set<CLIENT*> ClientSet
protected

Definition at line 147 of file Server.h.

◆ GroupKeyMap

typedef std::map<const std::string, CLIENT*> GroupKeyMap
protected

Definition at line 146 of file Server.h.

◆ GroupKeySet

typedef std::set<std::string> GroupKeySet

Definition at line 29 of file Server.h.

Constructor & Destructor Documentation

◆ Server()

Server ( const std::string &  name,
const std::string &  host,
const unsigned int  port,
const unsigned int  maxCCU 
)
inline
   @brief Public constructor
   @param name server name
   @param host host where to bind the server socket
   @param port port to listen on

s *

Parameters
maxCCUmax ccu

Definition at line 38 of file Server.h.

◆ ~Server()

virtual ~Server ( )
inlinevirtual

destructor

Definition at line 79 of file Server.h.

Member Function Documentation

◆ closeClient()

void closeClient ( CLIENT *  client)
inlineprotected

closes a client connection

Parameters
clientclient

Definition at line 181 of file Server.h.

◆ closeGroup()

void closeGroup ( GROUP *  group)
inlineprotected

closes a group connection

Parameters
groupgroup

Definition at line 223 of file Server.h.

◆ getClientByKey()

CLIENT * getClientByKey ( const std::string &  clientKey)
inline

retrieve a client by key, the client reference is acquired, must be released after usage

Parameters
clientKeyclient identification key
Returns
client or NULL

Definition at line 101 of file Server.h.

◆ getClientKeySet()

ClientKeySet getClientKeySet ( )
inline

get a copy of current client keys

Returns
client list

Definition at line 86 of file Server.h.

◆ getGroupByKey()

GROUP * getGroupByKey ( const std::string &  groupKey)
inline

retrieve a group by key, the group reference is acquired, must be released after usage

Parameters
groupKeygroup identification key
Returns
group or NULL

Definition at line 132 of file Server.h.

◆ getGroupKeySet()

ClientKeySet getGroupKeySet ( )
inline

get a copy of current group keys

Returns
group list

Definition at line 117 of file Server.h.

◆ setClientKey()

bool setClientKey ( CLIENT *  client,
const std::string &  clientKey 
)
inlineprotected

sets a client identification key

Parameters
clientclient
&clientKeyclient identification key
Returns
if setting the key was successful

Definition at line 155 of file Server.h.

◆ setGroupKey()

bool setGroupKey ( GROUP *  group,
const std::string &  groupKey 
)
inlineprotected

sets a group identification key

Parameters
groupgroup
&groupKeygroup identification key
Returns
if setting the key was successful

Definition at line 197 of file Server.h.

◆ setIOThreadCount()

void setIOThreadCount ( const unsigned int  ioThreadCount)
inline

Sets up the numbers of threads to handle IO and framing.

Parameters
ioThreadCountIO thread count

Definition at line 56 of file Server.h.

◆ setThreadPoolMaxElements()

void setThreadPoolMaxElements ( const unsigned int  maxElements)
inline

Sets up max number of elements in worker thread pool queue.

Parameters
maxElementsmax elements

Definition at line 72 of file Server.h.

◆ setWorkerThreadCount()

void setWorkerThreadCount ( const unsigned int  workerThreadCount)
inline

Sets up the number of workers that handle requests in thread pool.

Parameters
workerThreadCountnumber of workers in thread pool

Definition at line 64 of file Server.h.

Member Data Documentation

◆ clientKeyListsReadWriteLock

ReadWriteLock clientKeyListsReadWriteLock
protected

Definition at line 243 of file Server.h.

◆ clientKeyMap

ClientKeyMap clientKeyMap
protected

Definition at line 240 of file Server.h.

◆ clientKeySet

ClientKeySet clientKeySet
protected

Definition at line 241 of file Server.h.

◆ groupKeyListsReadWriteLock

ReadWriteLock groupKeyListsReadWriteLock
protected

Definition at line 248 of file Server.h.

◆ groupKeyMap

GroupKeyMap groupKeyMap
protected

Definition at line 245 of file Server.h.

◆ groupKeySet

GroupKeySet groupKeySet
protected

Definition at line 246 of file Server.h.

◆ host

std::string host
protected

Definition at line 234 of file Server.h.

◆ ioThreadCount

unsigned int ioThreadCount
protected

Definition at line 250 of file Server.h.

◆ maxCCU

unsigned int maxCCU
protected

Definition at line 236 of file Server.h.

◆ name

std::string name
protected

Definition at line 233 of file Server.h.

◆ port

unsigned int port
protected

Definition at line 235 of file Server.h.

◆ startUpBarrier

Barrier* startUpBarrier
protected

Definition at line 238 of file Server.h.

◆ workerThreadPoolCount

unsigned int workerThreadPoolCount
protected

Definition at line 251 of file Server.h.

◆ workerThreadPoolMaxElements

unsigned int workerThreadPoolMaxElements
protected

Definition at line 252 of file Server.h.


The documentation for this class was generated from the following file: