|
My Project
|
NPL Jabber Client class. More...
#include <ParaScriptingJabberClient.h>
Public Member Functions | |||||||
| NPLJabberClient (ParaEngine::INPLJabberClient *pProxy) | |||||||
| bool | IsValid () | ||||||
| check if object is invalid. More... | |||||||
| void | SetUser (const char *User) | ||||||
| The username to connect as. More... | |||||||
| const char * | GetUser () const | ||||||
| The username to connect as. More... | |||||||
| void | SetPriority (int nPriority) | ||||||
| Priority for this connection. More... | |||||||
| int | GetPriority () const | ||||||
| Priority for this connection. More... | |||||||
| void | SetPassword (const char *Password) | ||||||
| The password to use for connecting. More... | |||||||
| const char * | GetPassword () const | ||||||
| The password to use for connecting. More... | |||||||
| void | SetAutoLogin (bool AutoLogin) | ||||||
| Automatically log in on connection. More... | |||||||
| bool | GetAutoLogin () const | ||||||
| Automatically log in on connection. More... | |||||||
| void | SetAutoRoster (bool AutoRoster) | ||||||
| Automatically retrieve roster on connection. More... | |||||||
| bool | GetAutoRoster () const | ||||||
| Automatically retrieve roster on connection. More... | |||||||
| void | SetAutoIQErrors (bool AutoIQErrors) | ||||||
| Automatically send back 501/feature-not-implemented to IQs that have not been handled. More... | |||||||
| bool | GetAutoIQErrors () const | ||||||
| Automatically send back 501/feature-not-implemented to IQs that have not been handled. More... | |||||||
| void | SetAutoPresence (bool AutoPresence) | ||||||
| Automatically send presence on connection. More... | |||||||
| bool | GetAutoPresence () const | ||||||
| Automatically send presence on connection. More... | |||||||
| void | SetResource (const char *Resource) | ||||||
| The connecting resource. More... | |||||||
| const char * | GetResource () const | ||||||
| The connecting resource. More... | |||||||
| void | SetIsAuthenticated (bool IsAuthenticated) | ||||||
| Are we currently connected? | |||||||
| bool | GetIsAuthenticated () const | ||||||
| Are we currently connected? | |||||||
| void | SetServer (const char *Server) | ||||||
| The name of the server to connect to. More... | |||||||
| const char * | GetServer () const | ||||||
| The name of the server to connect to. More... | |||||||
| void | SetNetworkHost (const char *NetworkHost) | ||||||
| The address to use on the "to" attribute of the stream:stream. More... | |||||||
| const char * | GetNetworkHost () const | ||||||
| The address to use on the "to" attribute of the stream:stream. More... | |||||||
| void | SetPort (int Port) | ||||||
| Automatically send presence on connection. More... | |||||||
| int | GetPort () const | ||||||
| The TCP port to connect to. More... | |||||||
| void | SetPlaintextAuth (bool PlaintextAuth) | ||||||
| Allow plaintext authentication? default to false. | |||||||
| bool | GetPlaintextAuth () const | ||||||
| Allow plaintext authentication? default to false. | |||||||
| bool | IsSSLon () const | ||||||
| Is the current connection SSL/TLS protected? | |||||||
| bool | IsCompressionOn () const | ||||||
| Is the current connection XEP-138 compressed? | |||||||
| void | SetSSL (bool SSL) | ||||||
| Do SSL3/TLS1 on startup. | |||||||
| bool | GetSSL () const | ||||||
| Do SSL3/TLS1 on startup. | |||||||
| void | SetAutoStartTLS (bool AutoStartTLS) | ||||||
| Allow Start-TLS on connection, if the server supports it. | |||||||
| bool | GetAutoStartTLS () const | ||||||
| Allow Start-TLS on connection, if the server supports it. | |||||||
| void | SetAutoStartCompression (bool AutoStartCompression) | ||||||
| Allow start compression on connection, if the server supports it. | |||||||
| bool | GetAutoStartCompression () const | ||||||
| Allow start compression on connection, if the server supports it. | |||||||
| void | SetKeepAlive (float KeepAlive) | ||||||
| Time, in seconds, between keep-alive spaces. More... | |||||||
| float | GetKeepAlive () const | ||||||
| Time, in seconds, between keep-alive spaces. More... | |||||||
| void | SetAutoReconnect (float AutoReconnect) | ||||||
| Seconds before automatically reconnecting if the connection drops. More... | |||||||
| float | GetAutoReconnect () const | ||||||
| Seconds before automatically reconnecting if the connection drops. More... | |||||||
| const char * | GetServerVersion () const | ||||||
| The version string returned in the server's open stream element. More... | |||||||
| void | SetRequiresSASL (bool RequiresSASL) | ||||||
| Is SASL required? This will default to true in the future. More... | |||||||
| bool | GetRequiresSASL () const | ||||||
| Is SASL required? This will default to true in the future. More... | |||||||
| object | GetStatistics (const object &inout) | ||||||
| Returns a StatisticsStruct containing byte and stanza counts for the current active connection. More... | |||||||
| bool | Connect () | ||||||
| Connect to the server. More... | |||||||
| void | Close () | ||||||
| Close down the connection, as gracefully as possible. More... | |||||||
| bool | activate (const char *sDestination, const object &sCode) | ||||||
| activate or sending a message to a target This function is similar to NPL.activate(), except that it only accept Jabber ID as destination. 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 | Login () | ||||||
| Initiate the auth process. More... | |||||||
| bool | SetPresence (int t, const char *status, const char *show, int priority) | ||||||
/ Send a presence packet to the server /
| |||||||
| bool | Message (int t, const char *to, const char *body) | ||||||
/ Send a message packet to another user /
/
/
| |||||||
| bool | Message2 (const char *to, const char *body) | ||||||
Send a message packet to another user
| |||||||
| 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... | |||||||
| 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. | |||||||
| void | RemoveRosterItem (const char *to, const char *msg) | ||||||
| OBSOLETED: in Jabber, a contact list is called a roster / Remove an item from the roster. More... | |||||||
| 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 names as a string. More... | |||||||
| void | RegisterCreateAccount (const char *username, const char *password) | ||||||
| to create an account: More... | |||||||
| void | RegisterChangePassword (const char *password) | ||||||
| to change an account's password: More... | |||||||
| void | RegisterRemoveAccount () | ||||||
| to delete an account: More... | |||||||
| void | AddEventListener (int nListenerType, const char *callbackScript) | ||||||
| / More... | |||||||
| void | AddEventListener1 (const char *sListenerType, const char *callbackScript) | ||||||
| void | RemoveEventListener (int nListenerType, const char *callbackScript) | ||||||
| / 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... | |||||||
Public Attributes | |
| ParaEngine::INPLJabberClient * | m_pProxy |
NPL Jabber Client class.
| bool ParaScripting::NPLJabberClient::activate | ( | const char * | sDestination, |
| const object & | sCode | ||
| ) |
activate or sending a message to a target This function is similar to NPL.activate(), except that it only accept Jabber ID as destination.
| sDestination | format: JID[:neuron_filepath] JID or jabber ID is in the format: username e.g. "lixizhi@paraengine.com:script/network/client.lua". the target NPL runtime's neuron file will receive message by its activation function. "lixizhi@paraengine.com" if no neuron file is specified. the sCode will be regarded as an ordinary Jabber:XMPP:Chat message body. : please Node that offline message is NOT supported when a neuron_filepath is specified. TODO: when a neuron file receives a msg. The msg table automatically has following addition fields filled with valid values msg.sender: the sender's JID msg.time: the time at which the sender send a message. |
| sCode | If it is a string, it is regarded as a chunk of secure msg code that should be executed in the destination neuron file's runtime. If this is a table or number, it will be transmitted via a internal variable called "msg". When activating neurons on a remote network, only pure data table is allowed in the sCode. |
| void ParaScripting::NPLJabberClient::AddEventListener | ( | int | nListenerType, |
| const char * | callbackScript | ||
| ) |
/
/ add a NPL call back script to a given even listener /
/
| nListenerType | type of message listener. The user can register NPL callback script with any one listener type. enum JABBERLISTENER_TYPE { Jabber_OnPresence = 0,//We received a presence packet. Jabber_OnError, Jabber_OnRegistered,//After calling Register(), the registration succeeded or failed. Jabber_OnRegisterInfo,//after calling Register, information about the user is required. Fill in the given IQ with the requested information. Jabber_OnIQ,//We received an IQ packet. Jabber_OnMessage,//We received a message packet. Jabber_OnAuthError,//Authentication failed. The connection is not terminated if there is an auth error and there is at least one event handler for this event. Jabber_OnLoginRequired,//AutoLogin is false, and it's time to log in. |
Jabber_OnConnect, // The connection is connected, but no stream:stream has been sent, yet. Jabber_OnAuthenticate, // The connection is complete, and the user is authenticated. Jabber_OnDisconnect, // The connection is disconnected
Jabber_OnRosterEnd, //Fired when a roster result is completed being processed. Jabber_OnRosterBegin, // Fired when a roster result starts, before any OnRosterItem events fire. Jabber_OnRosterItem, //event for new roster items. A roster may belong to multiple groups };
/
| callbackScript | the script to be called when the listener event is raised. Usually parameters are stored in a NPL parameter called "msg". |
| bool ParaScripting::NPLJabberClient::AllowSubscription | ( | const char * | to, |
| bool | bAllow | ||
| ) |
this function is called in OnSubscription method to confirm or refuse a subscription request from another user.
| to | the JID |
| bAllow | true to allow subscription, false to deny |
| void ParaScripting::NPLJabberClient::ClearEventListener | ( | int | nListenerType | ) |
| void ParaScripting::NPLJabberClient::Close | ( | ) |
Close down the connection, as gracefully as possible.
| bool ParaScripting::NPLJabberClient::Connect | ( | ) |
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.
| bool ParaScripting::NPLJabberClient::GetAutoIQErrors | ( | ) | const |
Automatically send back 501/feature-not-implemented to IQs that have not been handled.
| bool ParaScripting::NPLJabberClient::GetAutoLogin | ( | ) | const |
Automatically log in on connection.
| bool ParaScripting::NPLJabberClient::GetAutoPresence | ( | ) | const |
Automatically send presence on connection.
| float ParaScripting::NPLJabberClient::GetAutoReconnect | ( | ) | const |
Seconds before automatically reconnecting if the connection drops.
-1 to disable, 0 for immediate. Default to 30 seconds
| bool ParaScripting::NPLJabberClient::GetAutoRoster | ( | ) | const |
Automatically retrieve roster on connection.
| float ParaScripting::NPLJabberClient::GetKeepAlive | ( | ) | const |
Time, in seconds, between keep-alive spaces.
default to 20f
| const char* ParaScripting::NPLJabberClient::GetNetworkHost | ( | ) | const |
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.
| const char* ParaScripting::NPLJabberClient::GetPassword | ( | ) | const |
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.
| int ParaScripting::NPLJabberClient::GetPort | ( | ) | const |
The TCP port to connect to.
default to 5222
| int ParaScripting::NPLJabberClient::GetPriority | ( | ) | const |
Priority for this connection.
| bool ParaScripting::NPLJabberClient::GetRequiresSASL | ( | ) | const |
Is SASL required? This will default to true in the future.
| const char* ParaScripting::NPLJabberClient::GetResource | ( | ) | const |
The connecting resource.
Used to identify a unique connection.
| const char* ParaScripting::NPLJabberClient::GetRoster | ( | ) |
Get a full roster.
| const char* ParaScripting::NPLJabberClient::GetRosterGroups | ( | ) |
OBSOLETED: The group names for the roster as a string.
each group name is separated by ; such as "general;friends;relatives;"
| const char* ParaScripting::NPLJabberClient::GetRosterItemDetail | ( | const char * | jid | ) |
OBSOLETED: Retrieve details of a given roster item.
| jid |
| const char* ParaScripting::NPLJabberClient::GetRosterItems | ( | ) |
OBSOLETED The Roster Item names as a string.
each name is separated by ; such as "Xizhi;Andy;Clayman;"
| const char* ParaScripting::NPLJabberClient::GetServer | ( | ) | const |
The name of the server to connect to.
| const char* ParaScripting::NPLJabberClient::GetServerVersion | ( | ) | const |
The version string returned in the server's open stream element.
Returns a StatisticsStruct containing byte and stanza counts for the current active connection.
| inout | the input|output table. usually this is an empty table. |
| const char* ParaScripting::NPLJabberClient::GetUser | ( | ) | const |
The username to connect as.
|
inline |
check if object is invalid.
| bool ParaScripting::NPLJabberClient::Login | ( | ) |
Initiate the auth process.
| bool ParaScripting::NPLJabberClient::Message | ( | int | t, |
| const char * | to, | ||
| const char * | body | ||
| ) |
/ Send a message packet to another user /
| t | What kind? public enum MessageType { / Normal message normal = -1, / Error message error, / Chat (one-to-one) message chat, / Groupchat groupchat, / Headline headline } |
/
| to | Who to send it to? |
/
| body | The message. |
| bool ParaScripting::NPLJabberClient::Message2 | ( | const char * | to, |
| const char * | body | ||
| ) |
Send a message packet to another user
| to | Who to send it to? |
| body | The message. |
| bool ParaScripting::NPLJabberClient::Register | ( | const char * | jid | ) |
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.
| jid | The user to register |
| void ParaScripting::NPLJabberClient::RegisterChangePassword | ( | const char * | password | ) |
to change an account's password:
| void ParaScripting::NPLJabberClient::RegisterCreateAccount | ( | const char * | username, |
| const char * | password | ||
| ) |
to create an account:
| void ParaScripting::NPLJabberClient::RegisterRemoveAccount | ( | ) |
to delete an account:
| void ParaScripting::NPLJabberClient::RemoveEventListener | ( | int | nListenerType, |
| const char * | callbackScript | ||
| ) |
/
/ remove a NPL call back script from a given even listener /
/
| nListenerType | type of message listener. The user can register NPL callback script with any one listener type. enum JABBERLISTENER_TYPE { Jabber_OnPresence = 0,//We received a presence packet. Jabber_OnError, Jabber_OnRegistered,//After calling Register(), the registration succeeded or failed. Jabber_OnRegisterInfo,//after calling Register, information about the user is required. Fill in the given IQ with the requested information. Jabber_OnIQ,//We received an IQ packet. Jabber_OnMessage,//We received a message packet. Jabber_OnAuthError,//Authentication failed. The connection is not terminated if there is an auth error and there is at least one event handler for this event. Jabber_OnLoginRequired,//AutoLogin is false, and it's time to log in. |
Jabber_OnConnect, // The connection is connected, but no stream:stream has been sent, yet. Jabber_OnAuthenticate, // The connection is complete, and the user is authenticated. Jabber_OnDisconnect, // The connection is disconnected
Jabber_OnRosterEnd, //Fired when a roster result is completed being processed. Jabber_OnRosterBegin, // Fired when a roster result starts, before any OnRosterItem events fire. Jabber_OnRosterItem, //event for new roster items. A roster may belong to multiple groups };
/
| callbackScript | the script to be called when the listener event is raised. Usually parameters are stored in a NPL parameter called "msg". |
| void ParaScripting::NPLJabberClient::RemoveRosterItem | ( | const char * | to, |
| const char * | msg | ||
| ) |
OBSOLETED: in Jabber, a contact list is called a roster / Remove an item from the roster.
/ This will have the side-effect of bi-directionally unsubscribing to/from the user. /
| to | The JID to remove |
| void ParaScripting::NPLJabberClient::ResetAllEventListeners | ( | ) |
clear all registered event listeners
| void ParaScripting::NPLJabberClient::SetAutoIQErrors | ( | bool | AutoIQErrors | ) |
Automatically send back 501/feature-not-implemented to IQs that have not been handled.
| void ParaScripting::NPLJabberClient::SetAutoLogin | ( | bool | AutoLogin | ) |
Automatically log in on connection.
| void ParaScripting::NPLJabberClient::SetAutoPresence | ( | bool | AutoPresence | ) |
Automatically send presence on connection.
| void ParaScripting::NPLJabberClient::SetAutoReconnect | ( | float | AutoReconnect | ) |
Seconds before automatically reconnecting if the connection drops.
-1 to disable, 0 for immediate. Default to 30 seconds
| void ParaScripting::NPLJabberClient::SetAutoRoster | ( | bool | AutoRoster | ) |
Automatically retrieve roster on connection.
| void ParaScripting::NPLJabberClient::SetKeepAlive | ( | float | KeepAlive | ) |
Time, in seconds, between keep-alive spaces.
default to 20f
| void ParaScripting::NPLJabberClient::SetNetworkHost | ( | const char * | NetworkHost | ) |
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.
| void ParaScripting::NPLJabberClient::SetPassword | ( | const char * | Password | ) |
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.
| void ParaScripting::NPLJabberClient::SetPort | ( | int | Port | ) |
Automatically send presence on connection.
| bool ParaScripting::NPLJabberClient::SetPresence | ( | int | t, |
| const char * | status, | ||
| const char * | show, | ||
| int | priority | ||
| ) |
/ Send a presence packet to the server /
| t | What 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 }
/
| status | How to show us? |
/
| show | away, dnd, etc. |
/
| priority | How to prioritize this connection. / Higher number mean higher priority. 0 minumum, 127 max. / -1 means this is a presence-only connection. |
| void ParaScripting::NPLJabberClient::SetPriority | ( | int | nPriority | ) |
Priority for this connection.
| void ParaScripting::NPLJabberClient::SetRequiresSASL | ( | bool | RequiresSASL | ) |
Is SASL required? This will default to true in the future.
| void ParaScripting::NPLJabberClient::SetResource | ( | const char * | Resource | ) |
The connecting resource.
Used to identify a unique connection.
| void ParaScripting::NPLJabberClient::SetServer | ( | const char * | Server | ) |
The name of the server to connect to.
| void ParaScripting::NPLJabberClient::SetUser | ( | const char * | User | ) |
The username to connect as.
| bool ParaScripting::NPLJabberClient::Subscribe | ( | const char * | jid, |
| const char * | name, | ||
| const char * | groups, | ||
| const char * | msg | ||
| ) |
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).
| jid | The address to subscribe to. |
| name | The displayed name of the contact. |
| groups | A list of groups the contact belongs to. separated by ";". Currently only one group is supported. |
| msg | A message sent along with the request. |
| void ParaScripting::NPLJabberClient::Unsubscribe | ( | const char * | to, |
| const char * | msg | ||
| ) |
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.
| to | The JID to remove |
| msg | A message to send along with the request. |
| bool ParaScripting::NPLJabberClient::WriteNPLMessage | ( | const char * | to, |
| const char * | neuronfile, | ||
| const char * | sCode | ||
| ) |
Send a NPL message.
| to | JID such as lxz@paraengine.com |
| neuronfile | a NPL table converted to secure code. |
| sCode | must be pure msg data, such as "msg = {x=0}" |
| bool ParaScripting::NPLJabberClient::WriteRawString | ( | const char * | rawstring | ) |
Send raw string.
1.8.12