Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

SUETcpServerSession Class Reference

Generic Tcp Session to be used with SUETcpServer. More...

#include <sue_tcps.hpp>

Inheritance diagram for SUETcpServerSession:

Inheritance graph
[legend]
Collaboration diagram for SUETcpServerSession:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual void HandleNewInput ()=0
 Hook for handling new input.

virtual void TcpServerSessionShutdownHook ()

Protected Methods

 SUETcpServerSession (int a_fd, int a_timeout, SUEEventSelector *a_selector, SUETcpServer *a_server, const char *a_greeting=0)
 Constructor.

virtual ~SUETcpServerSession ()
 Destructor.


Friends

class SUETcpServer

Detailed Description

Generic Tcp Session to be used with SUETcpServer.

A child class of SUETcpServerSession is the right place to implement your protocol. Create YOUR child class overriding the HandleNewInput and HandleSessionTerminatingEvent methods.

Note:
This class is used solely by SUETcpServer, that is, it is created and destroyed by SUETcpServer's (or its child) methods, and it is stored by the server so the server takes care about the appropriate cleanup. It exists as long as the corresponding session really exists.
The functions HandleSessionTimeout(), HandleRemoteClosing() and HandleReadError() are not reimplemented here so by default they shut the session down. If you need to perform some actions right when the session dies, put them into your destructor.
Examples:

chat.cpp.


Constructor & Destructor Documentation

SUETcpServerSession::SUETcpServerSession int    a_fd,
int    a_timeout,
SUEEventSelector   a_selector,
SUETcpServer   a_server,
const char *    a_greeting = 0
[protected]
 

Constructor.

Parameters:
a_fd  is the file descriptor of the accepted session
a_timeout  is the value of the timeout (in seconds) used to close idle sessions
a_selector  is the Selector object (used to deal with the file handler and timeout handler)
a_server  is the TcpServer whic created this session
a_greeting  is the message to send to the client at the very start of the session.

virtual SUETcpServerSession::~SUETcpServerSession   [protected, virtual]
 

Destructor.

Note:
Destructor made protected because only SUETcpServer is allowed to destroy its sessions


Member Function Documentation

virtual void SUETcpServerSession::HandleNewInput   [pure virtual]
 

Hook for handling new input.

This function is called whenever new data is read from the session channel (that is, select(2) told us there is possibility to read, and read(2) got more than zero chars from the session's file descriptor).

All the chars are appended to the inputbuffer before this function is called.

Implements SUEGenericDuplexSession.

Examples:
chat.cpp.

virtual void SUETcpServerSession::TcpServerSessionShutdownHook   [inline, virtual]
 

Examples:
chat.cpp.


Friends And Related Function Documentation

friend class SUETcpServer [friend]
 


The documentation for this class was generated from the following file:
Generated on Fri Feb 27 13:17:27 2004 for SUE Library by doxygen1.2.18