glooxd  0.3-svn
Public Member Functions | Protected Member Functions | List of all members
StreamBase Class Reference

#include <streambase.h>

Public Member Functions

 StreamBase (C2S &parent, ConfigManager &cm, gloox::ConnectionBase *connection, const gloox::LogSink &logInstance)
virtual ~StreamBase ()
void run ()
void setFeatures (const FeatureList &features)
gloox::ConnectionError recv (int timeout=-1)
void send (gloox::Tag *tag)
void send (const std::string &xml)
void send (const gloox::IQ &iq)
void disconnect (gloox::ConnectionError e, gloox::StreamError se=gloox::StreamErrorUndefined, const std::string &text=gloox::EmptyString)
gloox::ConnectionBase * connection ()
const gloox::LogSink & logInstance ()
const gloox::JID & jid () const
void setServer (const std::string &server)
void setUsername (const std::string &username)
void setResource (const std::string &resource)
void setStrictXMPP (bool enable)
void finishStreamFeature (StreamState state, gloox::ConnectionBase *conn=0)
void routeTag (gloox::Tag *tag)
const gloox::JID name () const
const std::string & id () const
void handleIncomingTag (gloox::Tag *tag)
void handleOutgoingTag (gloox::Tag *tag)

Protected Member Functions

void stampTag (gloox::Tag *tag)

Detailed Description

A class that abstracts a single client connection. Used by C2S.

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

Definition at line 47 of file streambase.h.

Constructor & Destructor Documentation

StreamBase ( C2S parent,
ConfigManager cm,
gloox::ConnectionBase *  connection,
const gloox::LogSink &  logInstance 
)

Creates a new StreamBase object. It handles all the aspects of a single client connection (login, etc).

Parameters
c2sThe parent C2S.
cmThe local ConfigManager.
connectionThe (usually) TCP connection used for communication with the client.
logInstanceThe LogSink to use for logging.

Definition at line 73 of file streambase.cpp.

~StreamBase ( )
virtual

Virtual destructor.

Definition at line 96 of file streambase.cpp.

Member Function Documentation

gloox::ConnectionBase* connection ( )
inline

Returns the current transport connection.

Returns
The current transport connection.

Definition at line 120 of file streambase.h.

void disconnect ( gloox::ConnectionError  e,
gloox::StreamError  se = gloox::StreamErrorUndefined,
const std::string &  text = gloox::EmptyString 
)

Sends a stream error and disconnects the client connection.

Parameters
eThe reason for the disconnect.
seThe stream error to send. If this is StreamErrorUndefined, no stream error will be sent.
textAn optional string describing the error.

Definition at line 142 of file streambase.cpp.

void finishStreamFeature ( StreamState  state,
gloox::ConnectionBase *  conn = 0 
)

Used by StreamFeature-derived classes, this function finishes processing of a given stream feature by adding (bitwise OR) a State to the current stream state, disabling the exclusive Handler (usually the StreamFeature that calls finishStreamfeature()), and optionally pluging a new connection on top of the current connection chain.

Parameters
stateThe StreamState to add.
connAn optional connection to use.

Definition at line 237 of file streambase.cpp.

void handleIncomingTag ( gloox::Tag *  tag)

Tags passed to this function should be addressed to the StreamBase instance and will be processed locally (i.e. they will not be sent to the remote client).

Parameters
tagA Tag to process.

Definition at line 269 of file streambase.cpp.

void handleOutgoingTag ( gloox::Tag *  tag)

Tags passed to this function should be addressed to the remote client and will be sent there (notwithstanding a set exclusive handler). They will not be otherwise processed locally.

Parameters
tagA Tag to forward.

Definition at line 287 of file streambase.cpp.

const std::string& id ( ) const
inline

Returns the client's internal unique ID.

Returns
The client's internal unique ID.

Definition at line 206 of file streambase.h.

const gloox::JID& jid ( ) const
inline

Returns the client's JID.

Returns
The client's JID.

Definition at line 132 of file streambase.h.

const gloox::LogSink& logInstance ( )
inline

Returns the LogSink instance for this StreamBase and all related objects.

Returns
The LogSink instance used in the current StreamBase instance.

Definition at line 126 of file streambase.h.

const gloox::JID name ( ) const

Returns the JID by which this StreamBase is addressable.

Returns
The JID by which this StreamBase is addressable.

Definition at line 247 of file streambase.cpp.

gloox::ConnectionError recv ( int  timeout = -1)

Use this periodically to receive data from the underlying client connection.

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

Definition at line 134 of file streambase.cpp.

void routeTag ( gloox::Tag *  tag)

Hands the tag over to the router.

Parameters
tagA Tag to route.

Definition at line 458 of file streambase.cpp.

void run ( )

Starts processing incoming events. Blocks if the threading parameter to the constructor is true.

Note
currently used only internally.

Definition at line 106 of file streambase.cpp.

void send ( gloox::Tag *  tag)

Sends the given Tag to the remote end.

Parameters
tagThe tag to send.

Definition at line 214 of file streambase.cpp.

void send ( const std::string &  xml)

Sends the given XML string to the remote end.

Parameters
xmlThe XML to send.

Definition at line 228 of file streambase.cpp.

void send ( const gloox::IQ &  iq)

Sends the given IQ to the remote end.

Parameters
iqThe IQ to send.

Definition at line 223 of file streambase.cpp.

void setFeatures ( const FeatureList features)
inline

Sets the supported stream features.

Parameters
featuresA list of supported stream features.

Definition at line 78 of file streambase.h.

void setResource ( const std::string &  resource)
inline

Used by the authentication routines, this function sets the resource the remote client bound or that got assigned by the SM.

Parameters
resourceThe resource.

Definition at line 161 of file streambase.h.

void setServer ( const std::string &  server)
inline

Used by the authentication routines, this function sets the domain part of the remote client's authorized JID. This is used if the authorization ID supplied has a different server part than the stream greeting's 'to' attribute.

Parameters
serverThe domain/server part of the JID.

Definition at line 141 of file streambase.h.

void setStrictXMPP ( bool  enable)
inline

Enables or disables aset of rules that enforce strict XMPP. Currently, only a version='1.0' stream attribute is required if this is enabled. Enabled by default.

Parameters
enableTrue to enable, false to disable strcit XMPP.
Since
0.3

Definition at line 172 of file streambase.h.

void setUsername ( const std::string &  username)
inline

Used by the authentication routines, this function sets the username the remote client authenticated as.

Parameters
usernameThe username.

Definition at line 151 of file streambase.h.

void stampTag ( gloox::Tag *  tag)
protected

Stamps a 'from' to the Tag and hands it over to routeTag().

Parameters
tagA Tag to route.

Definition at line 446 of file streambase.cpp.


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