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

MsgHandler< Header, Lock > Class Template Reference

Inherits NetHandler< Lock >< Lock >.

List of all members.


Detailed Description

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
class MsgHandler< Header, Lock >

A handler which reads and writes messages, each with a fixed-size message described by the struct Header.

Header must have a public length field allowing the payload length to be get/set.

Handlers should override connected (inherited from NetHandler); incoming_message(const Header&, databuf) to read messages; and end_messages(unsigned int) to be notified of stream closure.


Public Methods

bool write (Header &head, const OMessage &p)
 Populates the header with the payload length and writes a message.

bool write (Header &head, constbuf payload)
 Populates the header with the payload length and writes a message.

bool write (const Header &head, const OMessage &p)
 Copies the header, populates it with the payload length, and writes a message.

bool write (const Header &head, constbuf payload)
 Populates the header with the payload length and writes a message.

bool write (const Header &head)
 Writes a message with no payload.

bool write (constbuf payload)
 Writes a message with a default-constructed header.

bool write (string payload)
 Writes a message with a default-constructed header.

bool write_asis (const Header &p, constbuf payload)
 Writes a message without setting the payload length (use this only if the payload length is known to have been set properly).


Protected Methods

 MsgHandler (IOEventLoop &loop, IOHandle ioh, bool established=false)
 MsgHandler (IOEventLoop &loop)
virtual ~MsgHandler ()
virtual void incoming_message (const Header &head, constbuf buf)=0
 Invoked when a complete message has been received.

virtual void end_messages (unsigned int remaining)
 Invoked when the stream has been closed for reading, i.e., there cannot possibly be more incoming messages.


Constructor & Destructor Documentation

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
MsgHandler< Header, Lock >::MsgHandler IOEventLoop   loop,
IOHandle    ioh,
bool    established = false
[protected]
 

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
MsgHandler< Header, Lock >::MsgHandler IOEventLoop   loop [protected]
 

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
virtual MsgHandler< Header, Lock >::~MsgHandler   [protected, virtual]
 


Member Function Documentation

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
virtual void MsgHandler< Header, Lock >::end_messages unsigned int    remaining [protected, virtual]
 

Invoked when the stream has been closed for reading, i.e., there cannot possibly be more incoming messages.

Parameters:
remaining  the number of bytes left in the input buffer but not belonging to a message (should be 0 if the stream was closed cleanly).

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
virtual void MsgHandler< Header, Lock >::incoming_message const Header &    head,
constbuf    buf
[protected, pure virtual]
 

Invoked when a complete message has been received.

Parameters:
head  the message header.
buf  the message payload.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write string    payload
 

Writes a message with a default-constructed header.

Reimplemented from NetHandler< Lock >.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write constbuf    payload
 

Writes a message with a default-constructed header.

Reimplemented from NetHandler< Lock >.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write const Header &    head
 

Writes a message with no payload.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write const Header &    head,
constbuf    payload
 

Populates the header with the payload length and writes a message.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write const Header &    head,
const OMessage   p
 

Copies the header, populates it with the payload length, and writes a message.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write Header &    head,
constbuf    payload
 

Populates the header with the payload length and writes a message.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write Header &    head,
const OMessage   p
 

Populates the header with the payload length and writes a message.

template<class Header = LengthHeader, class Lock = __nmstl_no_lock>
bool MsgHandler< Header, Lock >::write_asis const Header &    p,
constbuf    payload
 

Writes a message without setting the payload length (use this only if the payload length is known to have been set properly).


The documentation for this class was generated from the following file:
Generated on Fri Dec 20 13:35:11 2002 for NMSTL