# class JBEngine | A Jabber engine. More...
Full name | `TelEngine::JBEngine`
Definition | `#include <libs/yjabber/yatejabber.h>`
Inherits | TelEngine::DebugEnabler [public ], TelEngine::GenObject [public ], TelEngine::Mutex [public ]
Inherited by | JBClientEngine, JBServerEngine
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- JBEngine (const char* name = "jbengine")
- virtual ~JBEngine ()
- inline unsigned int streamReadBuffer () const
- inline bool exiting () const
- inline void setExiting ()
- inline unsigned int redirectMax () const
- inline bool hasClientTls () const
- inline JBRemoteDomainDef* remoteDomainDef (const String& domain)
- virtual void destruct ()
- virtual void initialize (const NamedList& params)
- virtual void cleanup (bool final = false, bool waitTerminate = true)
- bool acceptConn (Socket* sock, SocketAddr& remote, JBStream::Type t, bool ssl = false)
- virtual JBStream* findStream (const String& id, JBStream::Type hint = JBStream::TypeCount)
- ObjList* findClientStreams (bool in, const JabberID& jid, int flags = 0xffffffff)
- ObjList* findClientStreams (bool in, const JabberID& jid, const ObjList& resources, int flags = 0xffffffff)
- JBClientStream* findClientStream (bool in, const JabberID& jid)
- virtual unsigned int dropAll (JBStream::Type type = JBStream::TypeCount, const JabberID& local = JabberID::empty(), const JabberID& remote = JabberID::empty(), XMPPError::Type error = XMPPError::NoError, const char* reason = 0)
- virtual void buildStreamName (String& name, const JBStream* stream)
- virtual bool hasDomain (const String& domain)
- virtual void processEvent (JBEvent* ev)
- virtual void returnEvent (JBEvent* ev, XMPPError::Type error = XMPPError::NoError, const char* reason = 0)
- virtual void encryptStream (JBStream* stream)
- virtual void connectStream (JBStream* stream)
- virtual void compressStream (JBStream* stream, const String& formats)
- virtual void buildDialbackKey (const String& id, const String& local, const String& remote, String& key)
- bool checkDupId (JBStream* stream)
- virtual void printXml (const JBStream* stream, bool send, XmlChild& xml) const
- virtual void printXml (const JBStream* stream, bool send, XmlFragment& frag) const

#### Protected Methods

- virtual void addStream (JBStream* stream)
- virtual void removeStream (JBStream* stream, bool delObj = true)
- virtual void stopStreamSets (bool waitTerminate = true)
- virtual void getStreamList (RefPointer& list, int type)
- inline void getStreamLists (RefPointer list[JBStream::TypeCount], int type = JBStream::TypeCount)
- JBStream* findStream (const String& id, JBStreamSetList* list)

#### Protected Members

- bool m_exiting
- JBRemoteDomainDef m_remoteDomain
- ObjList m_remoteDomains
- unsigned char m_restartMax
- unsigned int m_restartUpdInterval
- unsigned int m_setupTimeout
- unsigned int m_startTimeout
- unsigned int m_connectTimeout
- unsigned int m_srvTimeout
- unsigned int m_pingInterval
- unsigned int m_pingTimeout
- unsigned int m_idleTimeout
- unsigned int m_pptTimeoutC2s
- unsigned int m_pptTimeout
- unsigned int m_streamReadBuffer
- unsigned int m_maxIncompleteXml
- unsigned int m_redirectMax
- bool m_hasClientTls
- int m_printXml
- bool m_initialized

## Detailed Description

This class holds a Jabber engine

JBEngine (const char* name = "jbengine") | ### JBEngine

Constructor

Parameters:

name | Engine name

~JBEngine () | ### ~JBEngine

[virtual]

Destructor

inline unsigned int streamReadBuffer () | ### streamReadBuffer

[const]

Retrieve the stream read buffer length

Returns: Stream read buffer length

inline bool exiting () | ### exiting

[const]

Check if this engine is exiting

Returns: True if this engine is exiting

inline void setExiting () | ### setExiting

Set the exiting flag. Terminate all streams

inline unsigned int redirectMax () | ### redirectMax

[const]

Retrieve maximum redirect counter for outgoing streams

Returns: Maximum redirect counter for outgoing streams

inline bool hasClientTls () | ### hasClientTls

[const]

Check if TLS is available for outgoing streams

Returns: True if TLS is available for outgoing streams

inline JBRemoteDomainDef* remoteDomainDef (const String& domain) | ### remoteDomainDef

Find a remote domain definition. Return the default settings if not found. This method is not thread safe

Parameters:

domain | The domain to find

Returns: Valid JBRemoteDomainDef pointer

void destruct () | ### destruct

[virtual]

Cleanup streams. Stop all threads owned by this engine. Release memory

Reimplemented from GenObject.

void initialize (const NamedList& params) | ### initialize

[virtual]

Initialize the engine's parameters. Start private streams if requested

Parameters:

params | Engine's parameters

void cleanup (bool final = false, bool waitTerminate = true) | ### cleanup

[virtual]

Stop connect threads. Drop all streams. Stop all stream sets. Release memory if final

Parameters:

final | True if called from destructor
waitTerminate | True to wait for all streams to terminate

bool acceptConn (Socket* sock, SocketAddr& remote, JBStream::Type t, bool ssl = false) | ### acceptConn

Accept an incoming stream connection. Build a stream. Don't delete the socket if false is returned

Parameters:

sock | Accepted socket
remote | Remote ip and port
t | Expected stream type
ssl | True if the socket is already using SSL/TLS

Returns: True on success

JBStream* findStream (const String& id, JBStream::Type hint = JBStream::TypeCount) | ### findStream

[virtual]

Find a stream by its name. This method is thread safe

Parameters:

id | The internal id of the stream to find
hint | Optional stream type hint

Returns: Referenced JBStream pointer or 0

ObjList* findClientStreams (bool in, const JabberID& jid, int flags = 0xffffffff) | ### findClientStreams

Find all c2s streams whose local or remote bare jid matches a given one. Ignore destroying streams. This method is thread safe

Parameters:

in | True for incoming, false for outgoing
jid | JID to compare (the local one for outgoing, remote jid for incoming)
flags | Optional stream flag to match

Returns: List of referenced JBClientStream pointers or 0

ObjList* findClientStreams (bool in, const JabberID& jid, const ObjList& resources, int flags = 0xffffffff) | ### findClientStreams

Find all c2s streams whose local or remote bare jid matches a given one and their resource is found in the given list. Ignore destroying streams. This method is thread safe

Parameters:

in | True for incoming, false for outgoing
jid | JID to compare (the local one for outgoing, remote jid for incoming)
resources | The list of resources to match
flags | Optional stream flag to match

Returns: List of referenced JBClientStream pointers or 0

JBClientStream* findClientStream (bool in, const JabberID& jid) | ### findClientStream

Find a c2s stream by its local or remote jid. This method is thread safe

Parameters:

in | True for incoming, false for outgoing
jid | JID to compare (the local one for outgoing, remote jid for incoming)

Returns: Referenced JBClientStream pointer or 0

unsigned int dropAll (JBStream::Type type = JBStream::TypeCount, const JabberID& local = JabberID::empty(), const JabberID& remote = JabberID::empty(), XMPPError::Type error = XMPPError::NoError, const char* reason = 0) | ### dropAll

[virtual]

Terminate all streams matching type and/or local/remote jid

Parameters:

type | Stream type. Match all stream types if unknown
local | Optional local jid to match
remote | Optional remote jid to match
error | Optional error to be sent to the client
reason | Optional error text to be sent to the client

Returns: The number of stream terminated

void buildStreamName (String& name, const JBStream* stream) | ### buildStreamName

[virtual]

Build an internal stream name

Parameters:

name | Destination buffer
stream | Stream requesting it

bool hasDomain (const String& domain) | ### hasDomain

[virtual]

Check if a domain is serviced by this engine

Parameters:

domain | Domain to check

Returns: True if the given domain is serviced by this engine

void processEvent (JBEvent* ev) | ### processEvent

[virtual]

Process an event. The default implementation will return the event to this engine

Parameters:

ev | The event to process

void returnEvent (JBEvent* ev, XMPPError::Type error = XMPPError::NoError, const char* reason = 0) | ### returnEvent

[virtual]

Return an event to this engine. The default implementation will send an error if apropriate and delete the event

Parameters:

ev | The event to return
error | Optional error to be returned to the event's XML sender
reason | Optional text to be attached to the error

void encryptStream (JBStream* stream) | ### encryptStream

[virtual]

Start stream TLS

Parameters:

stream | The stream to enchrypt

void connectStream (JBStream* stream) | ### connectStream

[virtual]

Connect an outgoing stream

Parameters:

stream | The stream to connect

void compressStream (JBStream* stream, const String& formats) | ### compressStream

[virtual]

Start stream compression

Parameters:

stream | The stream to compress
formats | Supported formats

void buildDialbackKey (const String& id, const String& local, const String& remote, String& key) | ### buildDialbackKey

[virtual]

Build a dialback key

Parameters:

id | The stream id
local | Local domain
remote | Remote domain
key | The dialback key

bool checkDupId (JBStream* stream) | ### checkDupId

Check if an outgoing stream exists with the same id and remote peer

Parameters:

stream | The calling stream

Returns: True if a duplicate is found

void printXml (const JBStream* stream, bool send, XmlChild& xml) | ### printXml

[const virtual]

Print XML to output

Parameters:

stream | Stream requesting the operation
send | True if sending, false if receiving
xml | XML to print

void printXml (const JBStream* stream, bool send, XmlFragment& frag) | ### printXml

[const virtual]

Print an XML fragment to output

Parameters:

stream | Stream requesting the operation
send | True if sending, false if receiving
frag | XML fragment to print

void addStream (JBStream* stream) | ### addStream

[protected virtual]

Add a stream to one of the stream lists

Parameters:

stream | The stream to add

void removeStream (JBStream* stream, bool delObj = true) | ### removeStream

[protected virtual]

Remove a stream

Parameters:

stream | The stream to remove
delObj | True to release the stream, false to remove it from list without releasing it

void stopStreamSets (bool waitTerminate = true) | ### stopStreamSets

[protected virtual]

Stop all stream sets

Parameters:

waitTerminate | True to wait for all streams to terminate

void getStreamList (RefPointer& list, int type) | ### getStreamList

[protected virtual]

Retrieve the list of streams of a given type. Descendant must implement it

Parameters:

list | The destination list to set
type | Stream type

inline void getStreamLists (RefPointer list[JBStream::TypeCount], int type = JBStream::TypeCount) | ### getStreamLists

[protected]

Retrieve all streams

Parameters:

list | The destination list to set. The first index will be filled with the c2s streams list, the second index will be set to the s2s stream list
type | Optional stream type

JBStream* findStream (const String& id, JBStreamSetList* list) | ### findStream

[protected]

Find a stream by its name in a given set list

Parameters:

id | The name of the stream to find
list | The list to search for a stream

Returns: Referenced JBStream pointer or 0

bool m_exiting | ### m_exiting

[protected]

JBRemoteDomainDef m_remoteDomain | ### m_remoteDomain

[protected]

ObjList m_remoteDomains | ### m_remoteDomains

[protected]

unsigned char m_restartMax | ### m_restartMax

[protected]

unsigned int m_restartUpdInterval | ### m_restartUpdInterval

[protected]

unsigned int m_setupTimeout | ### m_setupTimeout

[protected]

unsigned int m_startTimeout | ### m_startTimeout

[protected]

unsigned int m_connectTimeout | ### m_connectTimeout

[protected]

unsigned int m_srvTimeout | ### m_srvTimeout

[protected]

unsigned int m_pingInterval | ### m_pingInterval

[protected]

unsigned int m_pingTimeout | ### m_pingTimeout

[protected]

unsigned int m_idleTimeout | ### m_idleTimeout

[protected]

unsigned int m_pptTimeoutC2s | ### m_pptTimeoutC2s

[protected]

unsigned int m_pptTimeout | ### m_pptTimeout

[protected]

unsigned int m_streamReadBuffer | ### m_streamReadBuffer

[protected]

unsigned int m_maxIncompleteXml | ### m_maxIncompleteXml

[protected]

unsigned int m_redirectMax | ### m_redirectMax

[protected]

bool m_hasClientTls | ### m_hasClientTls

[protected]

int m_printXml | ### m_printXml

[protected]

bool m_initialized | ### m_initialized

[protected]

Generated by: paulc on bussard on Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.