gloox  1.0.9
Public Types | Public Member Functions | Protected Attributes | List of all members
Bytestream Class Reference

#include <bytestream.h>

Inheritance diagram for Bytestream:
Inheritance graph
[legend]

Public Types

enum  StreamType { S5B, IBB }

Public Member Functions

 Bytestream (StreamType type, LogSink &logInstance, const JID &initiator, const JID &target, const std::string &sid)
virtual ~Bytestream ()
bool isOpen () const
virtual bool connect ()=0
virtual void close ()=0
virtual bool send (const std::string &data)=0
virtual ConnectionError recv (int timeout=-1)=0
const std::string & sid () const
StreamType type () const
const JIDtarget () const
const JIDinitiator () const
void registerBytestreamDataHandler (BytestreamDataHandler *bdh)
void removeBytestreamDataHandler ()

Protected Attributes

BytestreamDataHandlerm_handler
const LogSinkm_logInstance
const JID m_initiator
const JID m_target
StreamType m_type
std::string m_sid
bool m_open

Detailed Description

An abstraction of a single bytestream.

Used as a base class for InBand Bytestreams as well as SOCKS5 Bytestreams. You should not need to use this class directly.

Author
Jakob Schroeter js@ca.nosp@m.maya.nosp@m..net
Since
1.0

Definition at line 36 of file bytestream.h.

Member Enumeration Documentation

enum StreamType

Available stream types.

Enumerator:
S5B 

SOCKS5 Bytestream

IBB 

In-Band Bytestream

Definition at line 42 of file bytestream.h.

Constructor & Destructor Documentation

Bytestream ( StreamType  type,
LogSink logInstance,
const JID initiator,
const JID target,
const std::string &  sid 
)
inline

Creates a new Bytestream.

Parameters
typeThe stream type.
logInstanceA Logsink to use for logging. Obtain it from ClientBase::logInstance().
initiatorThe initiator of the stream (usually the sender).
targetThe target of the stream (usually the receiver).
sidThe stream's ID.

Definition at line 56 of file bytestream.h.

virtual ~Bytestream ( )
inlinevirtual

Virtual destructor.

Definition at line 65 of file bytestream.h.

Member Function Documentation

virtual void close ( )
pure virtual

Closes the bytestream.

Implemented in InBandBytestream, and SOCKS5Bytestream.

virtual bool connect ( )
pure virtual

This function starts the connection process.

Returns
True if a connection to a remote entity could be established, false otherwise.
Note
If false is returned you should pass this Bytestream object to SIProfileFT::dispose() for deletion.
Make sure you have a BytestreamDataHandler registered (using registerBytestreamDataHandler()) before calling this function.

Implemented in InBandBytestream, and SOCKS5Bytestream.

const JID& initiator ( ) const
inline

Returns the initiating entity's JID. If this bytestream is remote-initiated, this is the remote entity's JID. If it is local-initiated, this is the local JID.

Returns
The initiator's JID.

Definition at line 134 of file bytestream.h.

bool isOpen ( ) const
inline

Returns whether the bytestream is open, that is, accepted by both parties and ready to send/receive data.

Returns
Whether or not the bytestream is open.

Definition at line 72 of file bytestream.h.

virtual ConnectionError recv ( int  timeout = -1)
pure virtual

Call this function repeatedly to receive data. You should even do this if you use the bytestream to merely send data. May be a NOOP, depending on the actual stream type.

Parameters
timeoutThe timeout to use for select in microseconds. Default of -1 means blocking.
Returns
The state of the connection.

Implemented in SOCKS5Bytestream, and InBandBytestream.

void registerBytestreamDataHandler ( BytestreamDataHandler bdh)
inline

Use this function to register an object that will receive any notifications from the Bytestream instance. Only one BytestreamDataHandler can be registered at any one time.

Parameters
bdhThe BytestreamDataHandler-derived object to receive notifications.

Definition at line 142 of file bytestream.h.

void removeBytestreamDataHandler ( )
inline

Removes the registered BytestreamDataHandler.

Definition at line 148 of file bytestream.h.

virtual bool send ( const std::string &  data)
pure virtual

Use this function to send a chunk of data over an open bytestream. If the stream is not open or has been closed again (by the remote entity or locally), nothing is sent and false is returned. This function does any base64 encoding for you, if necessary.

Parameters
dataThe block of data to send.
Returns
True if the data has been sent (no guarantee of receipt), false in case of an error.

Implemented in SOCKS5Bytestream, and InBandBytestream.

const std::string& sid ( ) const
inline

Lets you retrieve the stream's ID.

Returns
The stream's ID.

Definition at line 114 of file bytestream.h.

const JID& target ( ) const
inline

Returns the target entity's JID. If this bytestream is remote-initiated, this is the local JID. If it is local-initiated, this is the remote entity's JID.

Returns
The target's JID.

Definition at line 127 of file bytestream.h.

StreamType type ( ) const
inline

Returns the stream's type.

Returns
The stream's type.

Definition at line 120 of file bytestream.h.

Member Data Documentation

BytestreamDataHandler* m_handler
protected

A handler for incoming data and open/close events.

Definition at line 153 of file bytestream.h.

const JID m_initiator
protected

The initiator's JID.

Definition at line 159 of file bytestream.h.

const LogSink& m_logInstance
protected

A LogSink instance to use for logging.

Definition at line 156 of file bytestream.h.

bool m_open
protected

Indicates whether or not the stream is open.

Definition at line 171 of file bytestream.h.

std::string m_sid
protected

The stream ID.

Definition at line 168 of file bytestream.h.

const JID m_target
protected

The target's JID.

Definition at line 162 of file bytestream.h.

StreamType m_type
protected

The stream type.

Definition at line 165 of file bytestream.h.


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