Easy Simple Network Library  0.3.7
Public Member Functions | List of all members
esnlib::Server Class Referenceabstract

Server class (interface) More...

#include <Server.h>

Public Member Functions

virtual bool Start (int port)=0
 
virtual bool Start (const std::string &ipstr, int port)=0
 
virtual void Stop ()=0
 Stop listening.
 
virtual bool Listening ()=0
 
virtual int GetCurrentPort ()=0
 
virtual std::string GetCurrentIp ()=0
 
virtual std::string GetDefaultLocalIp ()=0
 
virtual void Broadcast (IoBufferPtr data)=0
 
virtual int GetSessionCount ()=0
 
virtual int GetSessions (std::vector< SessionPtr > &sessions)=0
 
virtual SessionPtr GetSessionById (int id)=0
 
virtual void SetIdleTime (int idletype, int idletime)=0
 
virtual void SetIoHandler (IoHandlerPtr handler)=0
 
virtual void SetIoFilter (IoFilterPtr filter)=0
 
virtual void SetIoBufferManager (IoBufferManagerPtr manager)=0
 
virtual void SetIoServiceManager (IoServiceManagerPtr manager)=0
 
virtual IoBufferPtr GetFreeBuffer (int bufsize)=0
 
virtual bool HasGlobalData ()=0
 
virtual CommonDataPtr GetGlobalData ()=0
 
virtual bool EnableSsl (const std::string &certfile, const std::string &keyfile, const std::string &password, const std::string &verifyfile=std::string())=0
 
virtual bool HasSsl ()=0
 

Detailed Description

Server class (interface)

Member Function Documentation

virtual void esnlib::Server::Broadcast ( IoBufferPtr  data)
pure virtual

Broadcast data

Parameters
dataThe data
virtual bool esnlib::Server::EnableSsl ( const std::string &  certfile,
const std::string &  keyfile,
const std::string &  password,
const std::string &  verifyfile = std::string() 
)
pure virtual

Try to enable SSL(Secure Sockets Layer)

Parameters
certfileThe Cert. file
keyfileThe private key file
passwordThe password for the private key
verifyfileThe verify file
Returns
Return true if set up SSL successfully
virtual std::string esnlib::Server::GetCurrentIp ( )
pure virtual

Get local IP of the server

Returns
The current listening local IP of the server
virtual int esnlib::Server::GetCurrentPort ( )
pure virtual

Get current listening port of the server

Returns
Current listening port
virtual std::string esnlib::Server::GetDefaultLocalIp ( )
pure virtual

Get the local default IP of the server

Returns
The default IP of the server
virtual IoBufferPtr esnlib::Server::GetFreeBuffer ( int  bufsize)
pure virtual

Get a free buffer from the Buffer Manager

Parameters
bufsizeThe size of the free buffer
Returns
The pointer of the free buffer (IO buffer)
virtual CommonDataPtr esnlib::Server::GetGlobalData ( )
pure virtual

Get the global data of the server

Returns
The pointer of the global data
virtual SessionPtr esnlib::Server::GetSessionById ( int  id)
pure virtual

Get a session by its ID

Parameters
idThe session ID
Returns
The pointer of the session
virtual int esnlib::Server::GetSessionCount ( )
pure virtual

Get total number of all sessions

Returns
Total number of all sessions
virtual int esnlib::Server::GetSessions ( std::vector< SessionPtr > &  sessions)
pure virtual

Get all sessions

Parameters
sessionsThe vector used to save all the sessions
Returns
Total number of all sessions
virtual bool esnlib::Server::HasGlobalData ( )
pure virtual

Check whether the server has global data attached

Returns
Return true if the server has global data
virtual bool esnlib::Server::HasSsl ( )
pure virtual

Check whether the server has SSL(Secure Sockets Layer)

Returns
Return true if the server has SSL
virtual bool esnlib::Server::Listening ( )
pure virtual

Check whether the server is listening

Returns
Return true if the server is listening
virtual void esnlib::Server::SetIdleTime ( int  idletype,
int  idletime 
)
pure virtual

Set idle time for sessions

Parameters
idletypeThe idle type (1 for read idle, 2 for write idle, 0 for both)
idletimeThe idle time (in second)
virtual void esnlib::Server::SetIoBufferManager ( IoBufferManagerPtr  manager)
pure virtual

Set Buffer Manager (memory pool)

Parameters
managerThe pointer of the buffer manager
virtual void esnlib::Server::SetIoFilter ( IoFilterPtr  filter)
pure virtual

Set IO Filter

Parameters
filterThe pointer of the filter
virtual void esnlib::Server::SetIoHandler ( IoHandlerPtr  handler)
pure virtual

Set IO Handler

Parameters
handlerThe pointer of the handler
virtual void esnlib::Server::SetIoServiceManager ( IoServiceManagerPtr  manager)
pure virtual

Set IO Thread Manager (IO thread pool)

Parameters
managerThe pointer of the IO service manager
virtual bool esnlib::Server::Start ( int  port)
pure virtual

Start to listen

Parameters
portThe listening port
Returns
Return true if start to listen successfully
virtual bool esnlib::Server::Start ( const std::string &  ipstr,
int  port 
)
pure virtual

Start to listen

Parameters
ipstrLocal IP in string format
portThe listening port
Returns
Return true if start to listen successfully

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