PTLib
Version 2.10.10
|
This class handles the client side of a C2S (Client to Server) XMPP stream. More...
#include <xmpp_c2s.h>
Public Member Functions | |
StreamHandler (const JID &jid, const PString &pwd, PBoolean newAccount=false) | |
~StreamHandler () | |
virtual PBoolean | IsEstablished () const |
virtual PBoolean | Start (Transport *transport=0) |
PBoolean | Send (Stanza *stanza) |
Request the delivery of the specified stanza NOTE: the StreamHandler takes ownership of the stanza and will take care of deleting it. More... | |
void | SetVersion (WORD major, WORD minor) |
void | GetVersion (WORD &major, WORD &minor) const |
const JID & | GetJID () const |
PNotifierList & | SessionEstablishedHandlers () |
These notifier lists after when a client session is established (i.e. More... | |
PNotifierList & | SessionReleasedHandlers () |
PNotifierList & | ErrorHandlers () |
These notifier lists are fired when a XMPP stanza or a stream error is received. More... | |
PNotifierList & | MessageHandlers () |
PNotifierList & | PresenceHandlers () |
PNotifierList & | IQHandlers () |
PNotifierList & | IQNamespaceHandlers (const PString &xml_namespace) |
A notifier list for a specific namespace. More... | |
PNotifierList & | MessageSenderHandlers (const JID &from) |
A notifier list for a particular message originator. More... | |
virtual PBoolean | DiscoverItems (const PString &jid, PNotifier *responseHandler, const PString &node=PString::Empty()) |
JEP-0030 Service Discovery access methods. More... | |
virtual PBoolean | DiscoverInfo (const PString &jid, PNotifier *responseHandler, const PString &node=PString::Empty()) |
![]() | |
BaseStreamHandler () | |
~BaseStreamHandler () | |
virtual PBoolean | Stop (const PString &error=PString::Empty()) |
void | SetAutoReconnect (PBoolean b=true, long timeout=1000) |
PNotifierList & | ElementHandlers () |
Stream * | GetStream () |
virtual PBoolean | Write (const void *buf, PINDEX len) |
virtual PBoolean | Write (const PString &data) |
virtual PBoolean | Write (const PXML &pdu) |
virtual void | Main () |
User override function for the main execution routine of the thread. More... | |
![]() | |
bool | IsAutoDelete () const |
int | PXBlockOnChildTerminate (int pid, const PTimeInterval &timeout) |
int | PXBlockOnIO (int handle, int type, const PTimeInterval &timeout) |
void | PXAbortBlock () const |
void | PrintOn (ostream &strm) const |
Standard stream print function. More... | |
PThread (PINDEX, AutoDeleteFlag deletion=AutoDeleteThread, Priority priorityLevel=NormalPriority, const PString &threadName=PString::Empty()) | |
Create a new thread instance. More... | |
~PThread () | |
Destroy the thread, this simply calls the Terminate() function with all its restrictions and penalties. More... | |
virtual void | Restart () |
Restart a terminated thread using the same stack priority etc that was current when the thread terminated. More... | |
virtual void | Terminate () |
Terminate the thread. More... | |
virtual PBoolean | IsTerminated () const |
Determine if the thread has been terminated or ran to completion. More... | |
void | WaitForTermination () const |
Block and wait for the thread to terminate. More... | |
PBoolean | WaitForTermination (const PTimeInterval &maxWait) const |
Block and wait for the thread to terminate. More... | |
virtual void | Suspend (PBoolean susp=true) |
Suspend or resume the thread. More... | |
virtual void | Resume () |
Resume thread execution, this is identical to Suspend(false) . More... | |
virtual PBoolean | IsSuspended () const |
Determine if the thread is currently suspended. More... | |
virtual void | SetPriority (Priority priorityLevel) |
Set the priority of the thread relative to other threads in the current process. More... | |
virtual Priority | GetPriority () const |
Get the current priority of the thread in the current process. More... | |
virtual void | SetAutoDelete (AutoDeleteFlag deletion=AutoDeleteThread) |
Set the flag indicating thread object is to be automatically deleted when the thread ends. More... | |
void | SetNoAutoDelete () |
Reet the flag indicating thread object is to be automatically deleted when the thread ends. More... | |
virtual PString | GetThreadName () const |
Get the name of the thread. More... | |
virtual void | SetThreadName (const PString &name) |
Change the name of the thread. More... | |
virtual PThreadIdentifier | GetThreadId () const |
Get operating system specific thread identifier for this thread. More... | |
bool | GetTimes (Times ×) |
Get the thread execution times. More... | |
![]() | |
virtual | ~PObject () |
virtual PObject * | Clone () const |
Create a copy of the class on the heap. More... | |
virtual PINDEX | HashFunction () const |
This function yields a hash value required by the PDictionary class. More... | |
virtual const char * | GetClass (unsigned ancestor=0) const |
Get the current dynamic type of the object instance. More... | |
PBoolean | IsClass (const char *cls) const |
virtual PBoolean | InternalIsDescendant (const char *clsName) const |
Determine if the dynamic type of the current instance is a descendent of the specified class. More... | |
virtual Comparison | Compare (const PObject &obj) const |
Compare the two objects and return their relative rank. More... | |
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const |
Determine the byte wise comparison of two objects. More... | |
bool | operator== (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator!= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator< (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator> (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator<= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator>= (const PObject &obj) const |
Compare the two objects. More... | |
virtual void | ReadFrom (istream &strm) |
Input the contents of the object from the stream. More... | |
Protected Types | |
enum | StreamState { Null, RegStarted, TLSStarted, SASLStarted, NonSASLStarted, StreamSent, BindSent, SessionSent, Established } |
Protected Member Functions | |
virtual void | OnOpen (Stream &stream, INT) |
virtual void | OnClose (Stream &stream, INT) |
virtual void | StartRegistration () |
virtual void | StartAuthNegotiation () |
virtual void | OnSessionEstablished () |
virtual void | OnSessionReleased () |
virtual void | OnElement (PXML &pdu) |
virtual void | OnError (PXML &pdu) |
virtual void | OnMessage (XMPP::Message &pdu) |
virtual void | OnPresence (XMPP::Presence &pdu) |
virtual void | OnIQ (XMPP::IQ &pdu) |
virtual void | HandleNullState (PXML &pdu) |
virtual void | HandleRegStartedState (PXML &pdu) |
virtual void | HandleTLSStartedState (PXML &pdu) |
virtual void | HandleNonSASLStartedState (PXML &pdu) |
virtual void | HandleStreamSentState (PXML &pdu) |
virtual void | HandleBindSentState (PXML &pdu) |
virtual void | HandleSessionSentState (PXML &pdu) |
virtual void | HandleEstablishedState (PXML &pdu) |
virtual PBoolean | Discover (const PString &xmlns, const PString &jid, PNotifier *responseHandler, const PString &node) |
virtual void | SetState (StreamState s) |
![]() | |
PDECLARE_NOTIFIER (Stream, BaseStreamHandler, OnOpen) | |
PDECLARE_NOTIFIER (Stream, BaseStreamHandler, OnClose) | |
![]() | |
PObject () | |
Constructor for PObject, made protected so cannot ever create one on its own. More... | |
Protected Attributes | |
WORD | m_VersionMajor |
WORD | m_VersionMinor |
PString | m_StreamID |
PBoolean | m_NewAccount |
JID | m_JID |
const PString | m_Password |
PBoolean | m_HasBind |
PBoolean | m_HasSession |
PNotifierList | m_SessionEstablishedHandlers |
PNotifierList | m_SessionReleasedHandlers |
PNotifierList | m_ErrorHandlers |
PNotifierList | m_MessageHandlers |
PNotifierList | m_PresenceHandlers |
PNotifierList | m_IQHandlers |
PDictionary< PString, PNotifierList > | m_IQNamespaceHandlers |
PDictionary< JID, PNotifierList > | m_MessageSenderHandlers |
PMutex | m_PendingIQsLock |
StanzaList | m_PendingIQs |
StreamState | m_State |
![]() | |
Stream * | m_Stream |
PBoolean | m_AutoReconnect |
PTimeInterval | m_ReconnectTimeout |
PNotifierList | m_ElementHandlers |
![]() | |
bool | m_isProcess |
bool | m_autoDelete |
PINDEX | m_originalStackSize |
PString | m_threadName |
PMutex | m_threadNameMutex |
PThreadIdentifier | m_threadId |
|
protected |
XMPP::C2S::StreamHandler::StreamHandler | ( | const JID & | jid, |
const PString & | pwd, | ||
PBoolean | newAccount = false |
||
) |
XMPP::C2S::StreamHandler::~StreamHandler | ( | ) |
|
protectedvirtual |
|
virtual |
jid | JID to which a query will be send |
responseHandler | Handler function for responses |
node | Optional node |
|
virtual |
|
inline |
These notifier lists are fired when a XMPP stanza or a
stream error is received.
For the notifier lists to be fired the stream must be already in the established state (i.e. after the bind and the session state). The parameter passed to the notifiers is a reference to the received pdu
References m_ErrorHandlers.
void XMPP::C2S::StreamHandler::GetVersion | ( | WORD & | major, |
WORD & | minor | ||
) | const |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
inline |
References m_IQHandlers.
PNotifierList& XMPP::C2S::StreamHandler::IQNamespaceHandlers | ( | const PString & | xml_namespace | ) |
A notifier list for a specific namespace.
The list will be fired only upon receiving an IQ with the child element of the specified namespace
|
inlinevirtual |
References Established, and m_State.
|
inline |
References m_MessageHandlers.
PNotifierList& XMPP::C2S::StreamHandler::MessageSenderHandlers | ( | const JID & | from | ) |
A notifier list for a particular message originator.
The list will be fired only upon receiving a message from the specified jid. NOTE: if a matching notifier list is found and it's not emnpty, the generic MessageHandlers list IS NOT fired.
|
protectedvirtual |
|
protectedvirtual |
Reimplemented from XMPP::BaseStreamHandler.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
inline |
References m_PresenceHandlers.
Request the delivery of the specified stanza
NOTE: the StreamHandler takes ownership of the stanza and will take care of deleting it.
BIG NOTE: use this method and not Write() if you want to get a notification when an answer to an iq arrives
|
inline |
These notifier lists after when a client session is
established (i.e.
after the handshake and authentication steps are completed) or is released. The parameter passed to the notifiers is a reference to the stream handler
References m_SessionEstablishedHandlers.
|
inline |
References m_SessionReleasedHandlers.
|
protectedvirtual |
void XMPP::C2S::StreamHandler::SetVersion | ( | WORD | major, |
WORD | minor | ||
) |
Reimplemented from XMPP::BaseStreamHandler.
|
protectedvirtual |
|
protectedvirtual |
|
protected |
Referenced by ErrorHandlers().
|
protected |
|
protected |
|
protected |
Referenced by IQHandlers().
|
protected |
|
protected |
Referenced by MessageHandlers().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by PresenceHandlers().
|
protected |
Referenced by SessionEstablishedHandlers().
|
protected |
Referenced by SessionReleasedHandlers().
|
protected |
Referenced by IsEstablished().
|
protected |
|
protected |
|
protected |