JGSession Class Reference

A Jingle session. More...

#include <yatejingle.h>

Inheritance diagram for JGSession:

RefObject Mutex GenObject

List of all members.

Public Types

enum  State {
  Idle = 0, Pending = 1, Active = 2, Ending = 3,
  Destroy = 4
}
enum  Action {
  ActAccept, ActInitiate, ActReject, ActTerminate,
  ActTransport, ActTransportInfo, ActTransportCandidates, ActTransportAccept,
  ActContentInfo, ActDtmf, ActDtmfMethod, ActCount
}
enum  TransportType { TransportUnknown, TransportInfo, TransportCandidates }

Public Member Functions

virtual ~JGSession ()
bool outgoing () const
const Stringsid () const
const JabberIDlocal () const
const JabberIDremote () const
State state () const
const JBStreamstream () const
void * userData ()
void userData (void *userdata)
bool accept (XMLElement *description)
bool hangup (bool reject=false, const char *msg=0)
bool confirm (XMLElement *xml, XMPPError::Type error=XMPPError::NoError, const char *text=0, XMPPError::ErrorType type=XMPPError::TypeModify)
bool sendDtmf (const char *dtmf, bool buttonUp=true)
bool sendDtmfMethod (const char *method)
bool denyDtmfMethod (XMLElement *element)
bool acceptTransport (JGTransport *transport=0)
bool sendTransport (JGTransport *transport)
bool sendMessage (const char *msg)

Protected Member Functions

 JGSession (JGEngine *engine, JBStream *stream, const String &callerJID, const String &calledJID, XMLElement *media, XMLElement *transport, bool sid, const char *msg=0)
 JGSession (JGEngine *engine, JBEvent *event, const String &id, bool sid)
virtual void destroyed ()
void enqueue (JBEvent *event)
JGEventgetEvent (u_int64_t time)
bool sendStanza (XMLElement *stanza, bool confirmation=true)
JGEventdecodeJingle (JBEvent *jbev)
XMLElementcreateJingle (Action action, XMLElement *element1=0, XMLElement *element2=0)
bool sendTransport (JGTransport *transport, Action act)

Static Protected Member Functions

static const char * lookupState (int state)

Friends

class JGEvent
class JGEngine


Detailed Description

A Jingle session.

This class does the management of a Jingle session


Member Enumeration Documentation

enum Action

Jingle action enumeration

enum State

Session state enumeration

Jingle transport type enumeration


Constructor & Destructor Documentation

virtual ~JGSession (  )  [virtual]

Destructor. Hangup if Pending or Active

JGSession ( JGEngine engine,
JBStream stream,
const String callerJID,
const String calledJID,
XMLElement media,
XMLElement transport,
bool  sid,
const char *  msg = 0 
) [protected]

Constructor. Create an outgoing session

Parameters:
engine The engine that owns this session
stream The stream this session is bound to
callerJID The caller's full JID
calledJID The called party's full JID
media The session media description
transport The session transport method(s)
sid True to used 'sid' instead of 'id' as session id attribute
msg Optional message to be sent before session initiate

JGSession ( JGEngine engine,
JBEvent event,
const String id,
bool  sid 
) [protected]

Constructor. Create an incoming session.

Parameters:
engine The engine that owns this session
event A valid Jabber Jingle event with action session initiate
id Session id
sid True to used 'sid' instead of 'id' as session id attribute


Member Function Documentation

bool accept ( XMLElement description  ) 

Accept a Pending incoming session. This method is thread safe

Parameters:
description The media description element to send
Returns:
False if send failed

bool acceptTransport ( JGTransport transport = 0  )  [inline]

Send a 'transport-accept' element to the remote peer. This method is thread safe

Parameters:
transport Optional transport data to send
Returns:
False if send failed

bool confirm ( XMLElement xml,
XMPPError::Type  error = XMPPError::NoError,
const char *  text = 0,
XMPPError::ErrorType  type = XMPPError::TypeModify 
)

Confirm a received element. If the error is NoError a result stanza will be sent. Otherwise, an error stanza will be created and sent and the received element is consumed (attached to the sent error stanza)

Parameters:
xml The element to confirm
error The error condition
text Optional text to add to the error element
type Error type
Returns:
False if send failed or element is 0

XMLElement* createJingle ( Action  action,
XMLElement element1 = 0,
XMLElement element2 = 0 
) [protected]

Create an 'iq' of type 'set' with a 'jingle' child

Parameters:
action The action of the Jingle stanza
element1 Optional child element
element2 Optional child element
Returns:
Valid XMLElement pointer

JGEvent* decodeJingle ( JBEvent jbev  )  [protected]

Decode a valid jingle set event. Set the event's data on success

Parameters:
jbev The event to decode
Returns:
JGEvent pointer or 0

bool denyDtmfMethod ( XMLElement element  ) 

Deny a dtmf method request from remote peer

Parameters:
element The received 'iq' element with the method
Returns:
False if send failed

virtual void destroyed (  )  [protected, virtual]

Release this session and its memory

Reimplemented from RefObject.

void enqueue ( JBEvent event  )  [protected]

Enqueue a Jabber engine event. This method is thread safe

Parameters:
event The event event to process

JGEvent* getEvent ( u_int64_t  time  )  [protected]

Get a Jingle event from the queue. This method is thread safe

Parameters:
time Current time in miliseconds
Returns:
JGEvent pointer or 0

bool hangup ( bool  reject = false,
const char *  msg = 0 
)

Close a Pending or Active session This method is thread safe

Parameters:
reject True to reject. False to terminate gracefully
msg Optional message to send before hangup
Returns:
False if send failed

const JabberID& local (  )  const [inline]

Get the local peer's JID

Returns:
The local peer's JID

static const char* lookupState ( int  state  )  [inline, static, protected]

Get the name of a session state

Returns:
The name of a session state

References TelEngine::lookup().

bool outgoing (  )  const [inline]

Get the session direction

Returns:
True if it is an outgoing session

const JabberID& remote (  )  const [inline]

Get the remote peer's JID

Returns:
The remote peer's JID

bool sendDtmf ( const char *  dtmf,
bool  buttonUp = true 
)

Send a dtmf string to remote peer. If the string's lenght is greater then 1, each character is added as a 'dtmf' child of the jingle element

Parameters:
dtmf The dtmf string
buttonUp True to send button-up action. False to send button-down
Returns:
False if send failed

bool sendDtmfMethod ( const char *  method  ) 

Send a dtmf method to remote peer

Parameters:
method The method to send
Returns:
False if send failed

bool sendMessage ( const char *  msg  )  [inline]

Send a message to the remote peer. This method is thread safe

Parameters:
msg The message to send
Returns:
False on socket error

References JBMessage::createMessage().

bool sendStanza ( XMLElement stanza,
bool  confirmation = true 
) [protected]

Send a stanza to the remote peer

Parameters:
stanza The stanza to send
confirmation True if the stanza needs confirmation (add 'id' attribute)
Returns:
True on success

bool sendTransport ( JGTransport transport,
Action  act 
) [protected]

Send a transport related element to the remote peer

Parameters:
transport Transport data to send
act The element's type (info, accept, etc)
Returns:
True on success

bool sendTransport ( JGTransport transport  )  [inline]

Send a 'transport-info' element to the remote peer. This method is thread safe

Parameters:
transport The transport data
Returns:
False if send failed

References JGSession::sendTransport().

Referenced by JGSession::sendTransport().

const String& sid (  )  const [inline]

Get the session id

Returns:
The session id

State state (  )  const [inline]

Get the session state.

Returns:
The session state as enumeration.

const JBStream* stream (  )  const [inline]

Get the stream this session is bound to

Returns:
The stream this session is bound to

void userData ( void *  userdata  )  [inline]

Set the arbitrary user data of this session

Parameters:
userdata The new arbitrary user data's value

void* userData (  )  [inline]

Get the arbitrary user data of this session

Returns:
The arbitrary user data of this session


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

Generated on Sun Dec 7 21:36:13 2008 for Yate by  doxygen 1.5.7.1