My Project
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
ParaEngine::CNPLJabberClient Class Reference

NPL jabber client. More...

#include <NPLJabberClient.h>

Inheritance diagram for ParaEngine::CNPLJabberClient:
ParaEngine::INPLJabberClient

Public Types

enum  MessageType {
  MsgType_normal = -1, MsgType_error, MsgType_chat, MsgType_groupchat,
  MsgType_headline
}
 message type More...
 
typedef boost::bimap< int, std::string > StringMap_Type
 

Public Member Functions

 CNPLJabberClient (boost::asio::io_service &io_service, const char *sJID)
 Create a new jabber client instance with the given jabber client ID. More...
 
int ProcessMessage (int timeout=10)
 Use this periodically to receive data from the socket and to feed the parser. More...
 
virtual void handleLog (LogLevel level, LogArea area, const std::string &message)
 
virtual void onConnect ()
 
virtual void onDisconnect (ConnectionError e)
 
virtual bool onTLSConnect (const CertInfo &info)
 
virtual void handleMessage (const gloox::Message &stanza, MessageSession *)
 
virtual void handleMessageEvent (const JID &from, MessageEventType event)
 
virtual void handleChatState (const JID &from, ChatStateType state)
 
virtual void handleMessageSession (MessageSession *session)
 
virtual void onResourceBindError (ResourceBindError error)
 
virtual void onSessionCreateError (SessionCreateError error)
 
virtual void handleItemSubscribed (const JID &jid)
 
virtual void handleItemAdded (const JID &jid)
 
virtual void handleItemUnsubscribed (const JID &jid)
 
virtual void handleItemRemoved (const JID &jid)
 
virtual void handleItemUpdated (const JID &jid)
 
virtual void handleRoster (const Roster &roster)
 
virtual void handleRosterError (const gloox::IQ &)
 
virtual void handleRosterPresence (const RosterItem &item, const std::string &resource, gloox::Presence::PresenceType presence, const std::string &)
 
virtual void handleSelfPresence (const RosterItem &item, const std::string &resource, gloox::Presence::PresenceType presence, const std::string &)
 
virtual bool handleSubscriptionRequest (const JID &jid, const std::string &)
 
virtual bool handleUnsubscriptionRequest (const JID &jid, const std::string &)
 
virtual void handleNonrosterPresence (const gloox::Presence &)
 
virtual void handleRegistrationFields (const JID &, int fields, std::string instructions)
 
virtual void handleRegistrationResult (const JID &, RegistrationResult result)
 
virtual void handleAlreadyRegistered (const JID &)
 
virtual void handleDataForm (const JID &, const DataForm &)
 
virtual void handleOOB (const JID &, const OOB &oob)
 
bool Connect ()
 Connect to the server. More...
 
void Close ()
 Close down the connection, as gracefully as possible. More...
 
bool WriteNPLMessage (const char *to, const char *neuronfile, const char *sCode)
 Send a NPL message. More...
 
bool WriteRawString (const char *rawstring)
 Send raw string. More...
 
bool SendMessage (int t, const char *to, const char *body)
 / More...
 
bool SendMessage (const char *to, const char *body)
 Send a message packet to another user More...
 
bool Login ()
 Initiate the auth process. More...
 
bool SetPresence (int t, const char *status, const char *show, int priority)
 / More...
 
const char * GetRoster ()
 Get a full roster. More...
 
bool Subscribe (const char *jid, const char *name, const char *groups, const char *msg)
 Use this function to subscribe to a new JID. More...
 
void Unsubscribe (const char *to, const char *msg)
 Use this function to unsubscribe from a contact's presence. More...
 
virtual void RegisterCreateAccount (const char *username, const char *password)
 to create an account: More...
 
virtual void RegisterChangePassword (const char *password)
 to change an account's password: More...
 
virtual void RegisterRemoveAccount ()
 to delete an account: More...
 
virtual StatisticsJabber GetStatistics ()
 Returns a StatisticsStruct containing byte and stanza counts for the current active connection. More...
 
void RemoveRosterItem (const char *to, const char *msg)
 OBSOLETED.
 
bool AllowSubscription (const char *to, bool bAllow)
 this function is called in OnSubscription method to confirm or refuse a subscription request from another user. More...
 
void GetAgents ()
 OBSOLETED: Request a list of agents from the server.
 
bool Register (const char *jid)
 obsoleted: Attempt to register a new user. More...
 
const char * GetRosterItemDetail (const char *jid)
 OBSOLETED: Retrieve details of a given roster item. More...
 
const char * GetRosterGroups ()
 OBSOLETED The group names for the roster as a string. More...
 
const char * GetRosterItems ()
 OBSOLETED The Roster Item jids as a string. More...
 
void AddEventListener (int nListenerType, const char *callbackScript)
 
void AddEventListener1 (const char *sListenerType, const char *callbackScript)
 
void RemoveEventListener (int nListenerType, const char *callbackScript)
 remove a NPL call back script from a given even listener More...
 
void RemoveEventListener1 (const char *sListenerType, const char *callbackScript)
 
void ClearEventListener (int nListenerType)
 clear all NPL call back script from a given even listener More...
 
void ClearEventListener1 (const char *sListenerType)
 
void ResetAllEventListeners ()
 clear all registered event listeners More...
 
const std::string GetID ()
 Creates a string which is unique in the current instance and can be used as an ID for queries. More...
 
const string & GetStatus () const
 Returns the current status message.
 
int GetConnectionStatus () const
 This describes the possible states of a stream. More...
 
int GetAuthError () const
 Use this function to retrieve the type of the authentication error after it occurs and you received a ConnectionError of type ConnAuthenticationFailed from the ConnectionListener. More...
 
void WhitespacePing ()
 Sends a whitespace ping to the server. More...
 
void XmppPing (const string &sTo)
 Sends a XMPP Ping (XEP-0199) to the given JID. More...
 
const std::string & GetXmlLang () const
 Retrieves the value of the xml:lang attribute of the initial stream. More...
 
void SetXmlLang (const std::string &xmllang)
 
void SetClientCert (const std::string &clientKey, const std::string &clientCerts)
 Use this function to set the user's certificate and private key. More...
 
const char * GetUser ()
 The username to connect as. More...
 
void SetUser (const char *sValue)
 The username to connect as. More...
 
int GetPriority ()
 Priority for this connection. More...
 
void SetPriority (int nValue)
 Priority for this connection. More...
 
const char * GetPassword ()
 The password to use for connecting. More...
 
void SetPassword (const char *sValue)
 The password to use for connecting. More...
 
bool GetAutoLogin ()
 Automatically log in on connection. More...
 
void SetAutoLogin (bool nValue)
 Automatically log in on connection. More...
 
bool GetAutoRoster ()
 Automatically retrieve roster on connection. More...
 
void SetAutoRoster (bool nValue)
 Automatically retrieve roster on connection. More...
 
bool GetAutoIQErrors ()
 Automatically send back 501/feature-not-implemented to IQs that have not been handled. More...
 
void SetAutoIQErrors (bool nValue)
 Automatically send back 501/feature-not-implemented to IQs that have not been handled. More...
 
bool GetAutoPresence ()
 Automatically send presence on connection. More...
 
void SetAutoPresence (bool nValue)
 Automatically send presence on connection. More...
 
const char * GetResource ()
 The connecting resource. More...
 
void SetResource (const char *sValue)
 The connecting resource. More...
 
bool GetIsAuthenticated ()
 Are we currently connected?
 
void SetIsAuthenticated (bool bValue)
 Are we currently connected?
 
const char * GetServer ()
 The name of the server to connect to. More...
 
void SetServer (const char *Server)
 The name of the server to connect to. More...
 
const char * GetNetworkHost ()
 The address to use on the "to" attribute of the stream:stream. More...
 
void SetNetworkHost (const char *sValue)
 The address to use on the "to" attribute of the stream:stream. More...
 
int GetPort ()
 Automatically send presence on connection. More...
 
void SetPort (int nValue)
 Automatically send presence on connection. More...
 
bool GetPlaintextAuth ()
 Allow plaintext authentication? default to false.
 
void SetPlaintextAuth (bool bValue)
 Allow plaintext authentication? default to false.
 
bool IsSSLon ()
 Is the current connection SSL/TLS protected?
 
bool IsCompressionOn ()
 Is the current connection XEP-138 compressed?
 
bool GetSSL ()
 Do SSL3/TLS1 on startup.
 
void SetSSL (bool bValue)
 Do SSL3/TLS1 on startup.
 
bool GetAutoStartTLS ()
 Allow Start-TLS on connection, if the server supports it.
 
void SetAutoStartTLS (bool bValue)
 Allow Start-TLS on connection, if the server supports it.
 
bool GetAutoStartCompression ()
 Allow start compression on connection, if the server supports it.
 
void SetAutoStartCompression (bool bValue)
 Allow start compression on connection, if the server supports it.
 
float GetKeepAlive ()
 Time, in seconds, between keep-alive spaces. More...
 
void SetKeepAlive (float KeepAlive)
 Time, in seconds, between keep-alive spaces. More...
 
float GetAutoReconnect ()
 Seconds before automatically reconnecting if the connection drops. More...
 
void SetAutoReconnect (float AutoReconnect)
 Seconds before automatically reconnecting if the connection drops. More...
 
const char * GetServerVersion ()
 The version string returned in the server's open stream element. More...
 
bool GetRequiresSASL ()
 Is SASL required? This will default to true in the future. More...
 
void SetRequiresSASL (bool bValue)
 Is SASL required? This will default to true in the future. More...
 

Static Public Member Functions

static void AddStringMap (int nID, const char *sString)
 add string a string mapping. More...
 
static void ClearStringMap ()
 clear all string mapping
 

Protected Member Functions

virtual bool AddEvent (int nEventType, const char *precode=NULL, const char *postcode=NULL)
 Activate the given code of a type of event The activated script will send to the script buffer and wait for the script engine to execute it. More...
 
virtual bool CallEvent (int nEventType, const char *precode=NULL, const char *postcode=NULL)
 call the given code of a type of event It is similar to AddEvent, except that the callback functions are activated immediately and return after the callback returns. More...
 
const char * GetStringByID (int nID)
 get a string by id in the string map More...
 
int GetIDByString (const char *sString)
 get id by string in the string map More...
 
const string & GetJIDKey ()
 this is the unique key of this JC instance. More...
 
void SetJIDKey (const string &sJIDKey)
 never call this function, unless you know why. More...
 

Protected Attributes

Client * m_client
 
MessageSession * m_session
 
MessageEventFilter * m_messageEventFilter
 
ChatStateFilter * m_chatStateFilter
 
Registration * m_reg
 
JCOptions m_Options
 
bool m_bIsAuthenticated
 
float m_fKeepAlive
 
float m_fAutoReconnect
 
CJabberEventBinding m_eventbinding
 
string m_sUsername
 only used for creating a new user account. More...
 
string m_sPassword
 
string m_sStatus
 presence status
 
string m_sThisJIDKey
 this is the unique key of this JC instance. More...
 
boost::asio::io_service * m_pIOService
 dispatcher IO service object for the connection socket. More...
 
ParaEngine::mutex m_mutex
 

Static Protected Attributes

static StringMap_Type g_mapStringMap
 we will automatically encode NPL filename string if it is in this string map. More...
 

Detailed Description

NPL jabber client.

Member Enumeration Documentation

§ MessageType

message type

Enumerator
MsgType_normal 

Normal message

MsgType_error 

Error message

MsgType_chat 

Chat (one-to-one) message

MsgType_groupchat 

Groupchat

MsgType_headline 

Headline

Constructor & Destructor Documentation

§ CNPLJabberClient()

CNPLJabberClient::CNPLJabberClient ( boost::asio::io_service &  io_service,
const char *  sJID 
)

Create a new jabber client instance with the given jabber client ID.

It does not open a connection immediately.

Parameters
sJIDsuch as "lixizhi@paraengine.com"

Member Function Documentation

§ AddEvent()

bool ParaEngine::CNPLJabberClient::AddEvent ( int  nEventType,
const char *  precode = NULL,
const char *  postcode = NULL 
)
protectedvirtual

Activate the given code of a type of event The activated script will send to the script buffer and wait for the script engine to execute it.

The function will return immediately. So the script execution is asynchronous.

Parameters
nEventTypeevent type
precodethe script to be activated before the user-defined script code.
postcodethe script to be activated after the user-defined script code.
Returns
: true if there is a callback

§ AddEventListener()

void ParaEngine::CNPLJabberClient::AddEventListener ( int  nListenerType,
const char *  callbackScript 
)
virtual
Note
although the interface supports multiple listeners for the same event, the current implementation supports only one which makes the RemoveEventListener and ClearEventListener virtually the same.
Parameters
nListenerTypeenum from JabberEvents
callbackScriptan NPL callback script.

Implements ParaEngine::INPLJabberClient.

§ AddStringMap()

void ParaEngine::CNPLJabberClient::AddStringMap ( int  nID,
const char *  sString 
)
static

add string a string mapping.

We will automatically encode NPL filename string if it is in this string map. It means shorter message sent over the network. use AddStringMap whenever you want to add a string to the map. Please note, that the sender and the receiver must maintain the same string map in memory in order to have consistent string translation result. the function is static, it will apply to all client instances.

Parameters
nIDthe integer to encode the string. it is usually positive.
sStringthe string for the id. if input is NULL, it means removing the mapping of nID.

§ AllowSubscription()

bool ParaEngine::CNPLJabberClient::AllowSubscription ( const char *  to,
bool  bAllow 
)
virtual

this function is called in OnSubscription method to confirm or refuse a subscription request from another user.

Parameters
tothe JID
bAllowtrue to allow subscription, false to deny

Implements ParaEngine::INPLJabberClient.

§ CallEvent()

bool ParaEngine::CNPLJabberClient::CallEvent ( int  nEventType,
const char *  precode = NULL,
const char *  postcode = NULL 
)
protectedvirtual

call the given code of a type of event It is similar to AddEvent, except that the callback functions are activated immediately and return after the callback returns.

The function will return immediately. So the script execution is asynchronous.

Parameters
nEventTypeevent type
precodethe script to be activated before the user-defined script code.
postcodethe script to be activated after the user-defined script code.
Returns
: true if there is a callback

§ ClearEventListener()

void ParaEngine::CNPLJabberClient::ClearEventListener ( int  nListenerType)
virtual

clear all NPL call back script from a given even listener

Parameters
nListenerTypetype of message listener. The user can register NPL callback script with any one listener type.

Implements ParaEngine::INPLJabberClient.

§ Close()

void ParaEngine::CNPLJabberClient::Close ( )
virtual

Close down the connection, as gracefully as possible.

Implements ParaEngine::INPLJabberClient.

§ Connect()

bool ParaEngine::CNPLJabberClient::Connect ( )
virtual

Connect to the server.

This happens asynchronously, and could take a couple of seconds to get the full handshake completed. This will auth, send presence, and request roster info, if the Auto* properties are set.

Implements ParaEngine::INPLJabberClient.

§ GetAuthError()

int ParaEngine::CNPLJabberClient::GetAuthError ( ) const

Use this function to retrieve the type of the authentication error after it occurs and you received a ConnectionError of type ConnAuthenticationFailed from the ConnectionListener.

Returns
: Enumeration values: 0: AuthErrorUndefined No error occurred, or error condition is unknown. 1: SaslAborted The receiving entity acknowledges an <abort> element sent by the initiating entity; sent in reply to the <abort> element. 2: SaslIncorrectEncoding The data provided by the initiating entity could not be processed because the [BASE64] encoding is incorrect (e.g., because the encoding does not adhere to the definition in Section 3 of [BASE64]); sent in reply to a <response> element or an <auth> element with initial response data. 3: SaslInvalidAuthzid The authzid provided by the initiating entity is invalid, either because it is incorrectly formatted or because the initiating entity does not have permissions to authorize that ID; sent in reply to a <response> element or an <auth> element with initial response data. 4: SaslInvalidMechanism The initiating entity did not provide a mechanism or requested a mechanism that is not supported by the receiving entity; sent in reply to an <auth> element. 5: SaslMechanismTooWeak The mechanism requested by the initiating entity is weaker than server policy permits for that initiating entity; sent in reply to a <response> element or an <auth> element with initial response data. 6: SaslNotAuthorized The authentication failed because the initiating entity did not provide valid credentials (this includes but is not limited to the case of an unknown username); sent in reply to a <response> element or an <auth> element with initial response data. 7: SaslTemporaryAuthFailure The authentication failed because of a temporary error condition within the receiving entity; sent in reply to an <auth> element or <response> element. 8: NonSaslConflict XEP-0078: Resource Conflict 9: NonSaslNotAcceptable XEP-0078: Required Information Not Provided 10: NonSaslNotAuthorized XEP-0078: Incorrect Credentials

§ GetAutoIQErrors()

bool ParaEngine::CNPLJabberClient::GetAutoIQErrors ( )
inlinevirtual

Automatically send back 501/feature-not-implemented to IQs that have not been handled.

Implements ParaEngine::INPLJabberClient.

§ GetAutoLogin()

bool ParaEngine::CNPLJabberClient::GetAutoLogin ( )
inlinevirtual

Automatically log in on connection.

Implements ParaEngine::INPLJabberClient.

§ GetAutoPresence()

bool ParaEngine::CNPLJabberClient::GetAutoPresence ( )
inlinevirtual

Automatically send presence on connection.

Implements ParaEngine::INPLJabberClient.

§ GetAutoReconnect()

float ParaEngine::CNPLJabberClient::GetAutoReconnect ( )
inlinevirtual

Seconds before automatically reconnecting if the connection drops.

-1 to disable, 0 for immediate. Default to 30 seconds

Implements ParaEngine::INPLJabberClient.

§ GetAutoRoster()

bool ParaEngine::CNPLJabberClient::GetAutoRoster ( )
inlinevirtual

Automatically retrieve roster on connection.

Implements ParaEngine::INPLJabberClient.

§ GetConnectionStatus()

int ParaEngine::CNPLJabberClient::GetConnectionStatus ( ) const

This describes the possible states of a stream.

Returns
: 0: StateDisconnected The client is in disconnected state. 1: StateConnecting The client is currently trying to establish a connection. 2: StateConnected The client is connected to the server but authentication is not (yet) done.

§ GetID()

const std::string ParaEngine::CNPLJabberClient::GetID ( )

Creates a string which is unique in the current instance and can be used as an ID for queries.

Returns
: A unique string suitable for query IDs.

§ GetIDByString()

int ParaEngine::CNPLJabberClient::GetIDByString ( const char *  sString)
protected

get id by string in the string map

Returns
-1 if not found

§ GetJIDKey()

const string& ParaEngine::CNPLJabberClient::GetJIDKey ( )
inlineprotected

this is the unique key of this JC instance.

This is always the same as the bare JID of this instance. this key is set automatically, when an JC instance is created.

§ GetKeepAlive()

float ParaEngine::CNPLJabberClient::GetKeepAlive ( )
inlinevirtual

Time, in seconds, between keep-alive spaces.

default to 20f

Implements ParaEngine::INPLJabberClient.

§ GetNetworkHost()

const char* ParaEngine::CNPLJabberClient::GetNetworkHost ( )
inlinevirtual

The address to use on the "to" attribute of the stream:stream.

You can put the network hostname or IP address of the server to connect to. If none is specified, the Server will be used. Eventually, when SRV is supported, this will be deprecated.

Implements ParaEngine::INPLJabberClient.

§ GetPassword()

const char * ParaEngine::CNPLJabberClient::GetPassword ( )
virtual

The password to use for connecting.

This may be sent across the wire plaintext, if the server doesn't support digest and PlaintextAuth is true.

Implements ParaEngine::INPLJabberClient.

§ GetPort()

int ParaEngine::CNPLJabberClient::GetPort ( )
virtual

Automatically send presence on connection.

Implements ParaEngine::INPLJabberClient.

§ GetPriority()

int ParaEngine::CNPLJabberClient::GetPriority ( )
virtual

Priority for this connection.

Implements ParaEngine::INPLJabberClient.

§ GetRequiresSASL()

bool ParaEngine::CNPLJabberClient::GetRequiresSASL ( )
inlinevirtual

Is SASL required? This will default to true in the future.

Implements ParaEngine::INPLJabberClient.

§ GetResource()

const char * ParaEngine::CNPLJabberClient::GetResource ( )
virtual

The connecting resource.

Used to identify a unique connection.

Implements ParaEngine::INPLJabberClient.

§ GetRoster()

const char * ParaEngine::CNPLJabberClient::GetRoster ( )
virtual

Get a full roster.

Returns
: the returned string is NPL table of the following { {jid=string:jid, name=string,subscription=int:SubscriptionEnum, groups={string, string, ...}, resources={string, string, ...},}, {jid=string:jid, name=string,subscription=int:SubscriptionEnum, groups={string, string, ...}, resources={string, string, ...},}, {jid=string:jid, name=string,subscription=int:SubscriptionEnum, groups={string, string, ...}, resources={string, string, ...},}, ... }

Implements ParaEngine::INPLJabberClient.

§ GetRosterGroups()

const char * ParaEngine::CNPLJabberClient::GetRosterGroups ( )
virtual

OBSOLETED The group names for the roster as a string.

each group name is separated by ; such as "general;friends;relatives;"

Implements ParaEngine::INPLJabberClient.

§ GetRosterItemDetail()

const char * ParaEngine::CNPLJabberClient::GetRosterItemDetail ( const char *  jid)
virtual

OBSOLETED: Retrieve details of a given roster item.

Parameters
jid
Returns
null or string. the string is an NPL table of the following format "{ [1]={text=[[NickName]], presence=number,groupname=[[name]]}, [2]=...}" Presence Values: OFFLINE = 0;ONLINE = 1; AWAY = 2;XA = 3;DND = 4;CHATTY = 5; Usually a roster item only belongs to one group. so the table usually contains only one item at index 1.

Implements ParaEngine::INPLJabberClient.

§ GetRosterItems()

const char * ParaEngine::CNPLJabberClient::GetRosterItems ( )
virtual

OBSOLETED The Roster Item jids as a string.

each name is separated by ; such as "lixizhi@pala5.cn;Andy@pala5.cn;"

Implements ParaEngine::INPLJabberClient.

§ GetServer()

const char * ParaEngine::CNPLJabberClient::GetServer ( )
virtual

The name of the server to connect to.

Implements ParaEngine::INPLJabberClient.

§ GetServerVersion()

const char* ParaEngine::CNPLJabberClient::GetServerVersion ( )
inlinevirtual

The version string returned in the server's open stream element.

Implements ParaEngine::INPLJabberClient.

§ GetStatistics()

StatisticsJabber ParaEngine::CNPLJabberClient::GetStatistics ( )
virtual

Returns a StatisticsStruct containing byte and stanza counts for the current active connection.

Returns
: a struct containing the current connection's statistics.

Implements ParaEngine::INPLJabberClient.

§ GetStringByID()

const char * ParaEngine::CNPLJabberClient::GetStringByID ( int  nID)
protected

get a string by id in the string map

Returns
NULL if not found

§ GetUser()

const char * ParaEngine::CNPLJabberClient::GetUser ( )
virtual

The username to connect as.

Implements ParaEngine::INPLJabberClient.

§ GetXmlLang()

const std::string & ParaEngine::CNPLJabberClient::GetXmlLang ( ) const

Retrieves the value of the xml:lang attribute of the initial stream.

Default is 'en', i.e. if not changed by a call to setXmlLang().

§ Login()

bool ParaEngine::CNPLJabberClient::Login ( )
virtual

Initiate the auth process.

Implements ParaEngine::INPLJabberClient.

§ ProcessMessage()

int ParaEngine::CNPLJabberClient::ProcessMessage ( int  timeout = 10)

Use this periodically to receive data from the socket and to feed the parser.

Parameters
timeoutThe timeout in microseconds to use for select. Default of -1 means blocking until data was available.
Returns
: whether there is a connection error. 0 if connection is not established.

§ Register()

bool ParaEngine::CNPLJabberClient::Register ( const char *  jid)
virtual

obsoleted: Attempt to register a new user.

This will fire OnRegisterInfo to retrieve information about the new user, and OnRegistered when the registration is complete or failed.

Parameters
jidThe user to register

Implements ParaEngine::INPLJabberClient.

§ RegisterChangePassword()

void ParaEngine::CNPLJabberClient::RegisterChangePassword ( const char *  password)
virtual

to change an account's password:

  • connect to the server as usual
  • in onConnect() or at any later time call Registration::changePassword()

Implements ParaEngine::INPLJabberClient.

§ RegisterCreateAccount()

void ParaEngine::CNPLJabberClient::RegisterCreateAccount ( const char *  username,
const char *  password 
)
virtual

to create an account:

  • create the Client instance by passing it the server only, e.g. j = new Client( "example.net" );
  • in onConnect() (or some similar place) call Registration::fetchRegistrationFields()
  • in RegistrationHandler::handleRegistrationFields() set up an RegistrationFields struct with the desired username/password and call Registration::createAccount()

Implements ParaEngine::INPLJabberClient.

§ RegisterRemoveAccount()

void ParaEngine::CNPLJabberClient::RegisterRemoveAccount ( )
virtual

to delete an account:

  • connect to teh server as usual
  • in onConnect() or at any later time call Registration::removeAccount()

Implements ParaEngine::INPLJabberClient.

§ RemoveEventListener()

void ParaEngine::CNPLJabberClient::RemoveEventListener ( int  nListenerType,
const char *  callbackScript 
)
virtual

remove a NPL call back script from a given even listener

Parameters
nListenerTypetype of message listener. The user can register NPL callback script with any one listener type.
callbackScriptthe script to be called when the listener event is raised. Usually parameters are stored in a NPL parameter called "msg".

Implements ParaEngine::INPLJabberClient.

§ ResetAllEventListeners()

void ParaEngine::CNPLJabberClient::ResetAllEventListeners ( )
virtual

clear all registered event listeners

Implements ParaEngine::INPLJabberClient.

§ SendMessage() [1/2]

bool ParaEngine::CNPLJabberClient::SendMessage ( int  t,
const char *  to,
const char *  body 
)
virtual

/

/ Send a message packet to another user /

/

Parameters
ttype of MessageType

/

Parameters
toWho to send it to?

/

Parameters
bodyThe message.

Implements ParaEngine::INPLJabberClient.

§ SendMessage() [2/2]

bool ParaEngine::CNPLJabberClient::SendMessage ( const char *  to,
const char *  body 
)
virtual

Send a message packet to another user

Parameters
toWho to send it to?
bodyThe message.

Implements ParaEngine::INPLJabberClient.

§ SetAutoIQErrors()

void ParaEngine::CNPLJabberClient::SetAutoIQErrors ( bool  AutoIQErrors)
inlinevirtual

Automatically send back 501/feature-not-implemented to IQs that have not been handled.

Implements ParaEngine::INPLJabberClient.

§ SetAutoLogin()

void ParaEngine::CNPLJabberClient::SetAutoLogin ( bool  AutoLogin)
inlinevirtual

Automatically log in on connection.

Implements ParaEngine::INPLJabberClient.

§ SetAutoPresence()

void ParaEngine::CNPLJabberClient::SetAutoPresence ( bool  AutoPresence)
inlinevirtual

Automatically send presence on connection.

Implements ParaEngine::INPLJabberClient.

§ SetAutoReconnect()

void ParaEngine::CNPLJabberClient::SetAutoReconnect ( float  AutoReconnect)
inlinevirtual

Seconds before automatically reconnecting if the connection drops.

-1 to disable, 0 for immediate. Default to 30 seconds

Implements ParaEngine::INPLJabberClient.

§ SetAutoRoster()

void ParaEngine::CNPLJabberClient::SetAutoRoster ( bool  AutoRoster)
inlinevirtual

Automatically retrieve roster on connection.

Implements ParaEngine::INPLJabberClient.

§ SetClientCert()

void ParaEngine::CNPLJabberClient::SetClientCert ( const std::string &  clientKey,
const std::string &  clientCerts 
)

Use this function to set the user's certificate and private key.

The certificate will be presented to the server upon request and can be used for SASL EXTERNAL authentication. The user's certificate file should be a bundle of more than one certificate in PEM format. The first one in the file should be the user's certificate, each cert following that one should have signed the previous one.

Note
These certificates are not necessarily the same as those used to verify the server's certificate.
Parameters
clientKeyThe absolute path to the user's private key in PEM format.
clientCertsA path to a certificate bundle in PEM format.

§ SetJIDKey()

void ParaEngine::CNPLJabberClient::SetJIDKey ( const string &  sJIDKey)
inlineprotected

never call this function, unless you know why.

§ SetKeepAlive()

void ParaEngine::CNPLJabberClient::SetKeepAlive ( float  KeepAlive)
inlinevirtual

Time, in seconds, between keep-alive spaces.

default to 20f

Implements ParaEngine::INPLJabberClient.

§ SetNetworkHost()

void ParaEngine::CNPLJabberClient::SetNetworkHost ( const char *  NetworkHost)
inlinevirtual

The address to use on the "to" attribute of the stream:stream.

/ You can put the network hostname or IP address of the server to connect to. / If none is specified, the Server will be used. / Eventually, when SRV is supported, this will be deprecated.

Implements ParaEngine::INPLJabberClient.

§ SetPassword()

void ParaEngine::CNPLJabberClient::SetPassword ( const char *  Password)
virtual

The password to use for connecting.

This may be sent across the wire plaintext, if the server doesn't support digest and PlaintextAuth is true.

Implements ParaEngine::INPLJabberClient.

§ SetPort()

void ParaEngine::CNPLJabberClient::SetPort ( int  Port)
virtual

Automatically send presence on connection.

Implements ParaEngine::INPLJabberClient.

§ SetPresence()

bool ParaEngine::CNPLJabberClient::SetPresence ( int  t,
const char *  status,
const char *  show,
int  priority 
)
virtual

/

/ Send a presence packet to the server /

/

Parameters
tWhat kind? public enum PresenceType { /

/ None specified /

available = -1, /

/ May I subscribe to you? /

subscribe, /

/ Yes, you may subscribe. /

subscribed, /

/ Unsubscribe from this entity. /

unsubscribe, /

/ No, you may not subscribe. /

unsubscribed, /

/ Offline /

unavailable, /

/ server-side only. /

probe, /

/ A presence error. /

error, /

/ Invisible presence: we're unavailable to them, but still see / theirs. /

invisible }

/

Parameters
statusHow to show us?

/

Parameters
showaway, dnd, etc.

/

Parameters
priorityHow to prioritize this connection. / Higher number mean higher priority. 0 minumum, 127 max. / -1 means this is a presence-only connection.

Implements ParaEngine::INPLJabberClient.

§ SetPriority()

void ParaEngine::CNPLJabberClient::SetPriority ( int  nPriority)
inlinevirtual

Priority for this connection.

Implements ParaEngine::INPLJabberClient.

§ SetRequiresSASL()

void ParaEngine::CNPLJabberClient::SetRequiresSASL ( bool  RequiresSASL)
virtual

Is SASL required? This will default to true in the future.

Implements ParaEngine::INPLJabberClient.

§ SetResource()

void ParaEngine::CNPLJabberClient::SetResource ( const char *  Resource)
inlinevirtual

The connecting resource.

Used to identify a unique connection.

Implements ParaEngine::INPLJabberClient.

§ SetServer()

void ParaEngine::CNPLJabberClient::SetServer ( const char *  Server)
virtual

The name of the server to connect to.

Implements ParaEngine::INPLJabberClient.

§ SetUser()

void ParaEngine::CNPLJabberClient::SetUser ( const char *  User)
virtual

The username to connect as.

Implements ParaEngine::INPLJabberClient.

§ Subscribe()

bool ParaEngine::CNPLJabberClient::Subscribe ( const char *  jid,
const char *  name,
const char *  groups,
const char *  msg 
)
virtual

Use this function to subscribe to a new JID.

The contact is added to the roster automatically (by compliant servers, as required by RFC 3921).

Parameters
jidThe address to subscribe to.
nameThe displayed name of the contact.
groupsA list of groups the contact belongs to. separated by ";". Currently only one group is supported.
msgA message sent along with the request.

Implements ParaEngine::INPLJabberClient.

§ Unsubscribe()

void ParaEngine::CNPLJabberClient::Unsubscribe ( const char *  to,
const char *  msg 
)
virtual

Use this function to unsubscribe from a contact's presence.

You will no longer receive presence from this contact. This will have the side-effect of bi-directionally unsubscribing to/from the user.

Parameters
toThe JID to remove
msgA message to send along with the request.

Implements ParaEngine::INPLJabberClient.

§ WhitespacePing()

void ParaEngine::CNPLJabberClient::WhitespacePing ( )

Sends a whitespace ping to the server.

§ WriteNPLMessage()

bool ParaEngine::CNPLJabberClient::WriteNPLMessage ( const char *  to,
const char *  neuronfile,
const char *  sCode 
)
virtual

Send a NPL message.

The message is queued in a output message queue and this function returns immediately.

Parameters
msga NPL table converted to secure code.
Returns
true if message is sent to output queue. if the queue is full, the function returns false. and the caller typically reports a service unavailable message.

The current NPL message is sent via a special normal chat message subtype: MsgType_normal subject: NI:id or NF:string body: msg table scode

Implements ParaEngine::INPLJabberClient.

§ WriteRawString()

bool ParaEngine::CNPLJabberClient::WriteRawString ( const char *  rawstring)
virtual

Send raw string.

Implements ParaEngine::INPLJabberClient.

§ XmppPing()

void ParaEngine::CNPLJabberClient::XmppPing ( const string &  sTo)

Sends a XMPP Ping (XEP-0199) to the given JID.

There is currently no way to know whether the remote entity answered (other than registering an IQ handler for the urn:xmpp:ping namespace).

Member Data Documentation

§ g_mapStringMap

ParaEngine::CNPLJabberClient::StringMap_Type ParaEngine::CNPLJabberClient::g_mapStringMap
staticprotected

we will automatically encode NPL filename string if it is in this string map.

It means shorter message sent over the network. use AddStringMap whenever you want to add a string to the map. Please note, that the sender and the receiver must maintain the same string map in memory in order to have consistent string translation result.

§ m_pIOService

boost::asio::io_service* ParaEngine::CNPLJabberClient::m_pIOService
protected

dispatcher IO service object for the connection socket.

§ m_sThisJIDKey

string ParaEngine::CNPLJabberClient::m_sThisJIDKey
protected

this is the unique key of this JC instance.

This is always the same as the bare JID of this instance. this key is set automatically, when an JC instance is created.

§ m_sUsername

string ParaEngine::CNPLJabberClient::m_sUsername
protected

only used for creating a new user account.


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