gloox  1.0.20
Public Types | Public Member Functions | Protected Attributes | List of all members
Bytestream Class Referenceabstract

#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 Schröter

Definition at line 36 of file bytestream.h.

Member Enumeration Documentation

◆ StreamType

enum StreamType

Available stream types.


SOCKS5 Bytestream


In-Band Bytestream

Definition at line 42 of file bytestream.h.

Constructor & Destructor Documentation

◆ Bytestream()

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.

◆ ~Bytestream()

virtual ~Bytestream ( )

Virtual destructor.

Definition at line 65 of file bytestream.h.

Member Function Documentation

◆ close()

virtual void close ( )
pure virtual

Closes the bytestream.

Implemented in InBandBytestream, and SOCKS5Bytestream.

◆ connect()

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.

◆ initiator()

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.

◆ isOpen()

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.

◆ recv()

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.

◆ registerBytestreamDataHandler()

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.

◆ removeBytestreamDataHandler()

void removeBytestreamDataHandler ( )

Removes the registered BytestreamDataHandler.

Definition at line 148 of file bytestream.h.

◆ send()

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.

◆ sid()

const std::string& sid ( ) const

Lets you retrieve the stream's ID.

The stream's ID.

Definition at line 114 of file bytestream.h.

◆ target()

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.

◆ type()

StreamType type ( ) const

Returns the stream's type.

The stream's type.

Definition at line 120 of file bytestream.h.

Member Data Documentation

◆ m_handler

BytestreamDataHandler* m_handler

A handler for incoming data and open/close events.

Definition at line 153 of file bytestream.h.

◆ m_initiator

const JID m_initiator

The initiator's JID.

Definition at line 159 of file bytestream.h.

◆ m_logInstance

const LogSink& m_logInstance

A LogSink instance to use for logging.

Definition at line 156 of file bytestream.h.

◆ m_open

bool m_open

Indicates whether or not the stream is open.

Definition at line 171 of file bytestream.h.

◆ m_sid

std::string m_sid

The stream ID.

Definition at line 168 of file bytestream.h.

◆ m_target

const JID m_target

The target's JID.

Definition at line 162 of file bytestream.h.

◆ m_type

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: