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

#include <bytestream.h>

Inheritance diagram for Bytestream:
Inheritance graph

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

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.

Jakob Schroeter

Definition at line 36 of file bytestream.h.

Member Enumeration Documentation

enum StreamType

Available stream types.


SOCKS5 Bytestream


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 

Creates a new Bytestream.

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 ( )

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.

True if a connection to a remote entity could be established, false otherwise.
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

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.

The initiator's JID.

Definition at line 134 of file bytestream.h.

bool isOpen ( ) const

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

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.

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

Implemented in SOCKS5Bytestream, and InBandBytestream.

void registerBytestreamDataHandler ( BytestreamDataHandler bdh)

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.

bdhThe BytestreamDataHandler-derived object to receive notifications.

Definition at line 142 of file bytestream.h.

void removeBytestreamDataHandler ( )

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.

dataThe block of data to send.
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

Lets you retrieve the stream's ID.

The stream's ID.

Definition at line 114 of file bytestream.h.

const JID& target ( ) const

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.

The target's JID.

Definition at line 127 of file bytestream.h.

StreamType type ( ) const

Returns the stream's type.

The stream's type.

Definition at line 120 of file bytestream.h.

Member Data Documentation

BytestreamDataHandler* m_handler

A handler for incoming data and open/close events.

Definition at line 153 of file bytestream.h.

const JID m_initiator

The initiator's JID.

Definition at line 159 of file bytestream.h.

const LogSink& m_logInstance

A LogSink instance to use for logging.

Definition at line 156 of file bytestream.h.

bool m_open

Indicates whether or not the stream is open.

Definition at line 171 of file bytestream.h.

std::string m_sid

The stream ID.

Definition at line 168 of file bytestream.h.

const JID m_target

The target's JID.

Definition at line 162 of file bytestream.h.

StreamType m_type

The stream type.

Definition at line 165 of file bytestream.h.

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