Public Member Functions | ||||||||||
NPLJabberClient (::ParaEngine::INPLJabberClient *pProxy) | ||||||||||
bool | IsValid () | |||||||||
check if object is invalid. | ||||||||||
void | SetUser (const char *User) | |||||||||
The username to connect as. | ||||||||||
const char * | GetUser () const | |||||||||
The username to connect as. | ||||||||||
void | SetPriority (int nPriority) | |||||||||
Priority for this connection. | ||||||||||
int | GetPriority () const | |||||||||
Priority for this connection. | ||||||||||
void | SetPassword (const char *Password) | |||||||||
The password to use for connecting. | ||||||||||
const char * | GetPassword () const | |||||||||
The password to use for connecting. | ||||||||||
void | SetAutoLogin (bool AutoLogin) | |||||||||
Automatically log in on connection. | ||||||||||
bool | GetAutoLogin () const | |||||||||
Automatically log in on connection. | ||||||||||
void | SetAutoRoster (bool AutoRoster) | |||||||||
Automatically retrieve roster on connection. | ||||||||||
bool | GetAutoRoster () const | |||||||||
Automatically retrieve roster on connection. | ||||||||||
void | SetAutoIQErrors (bool AutoIQErrors) | |||||||||
Automatically send back 501/feature-not-implemented to IQs that have not been handled. | ||||||||||
bool | GetAutoIQErrors () const | |||||||||
Automatically send back 501/feature-not-implemented to IQs that have not been handled. | ||||||||||
void | SetAutoPresence (bool AutoPresence) | |||||||||
Automatically send presence on connection. | ||||||||||
bool | GetAutoPresence () const | |||||||||
Automatically send presence on connection. | ||||||||||
void | SetResource (const char *Resource) | |||||||||
The connecting resource. | ||||||||||
const char * | GetResource () const | |||||||||
The connecting resource. | ||||||||||
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. | ||||||||||
const char * | GetServer () const | |||||||||
The name of the server to connect to. | ||||||||||
void | SetNetworkHost (const char *NetworkHost) | |||||||||
The address to use on the "to" attribute of the stream:stream. | ||||||||||
const char * | GetNetworkHost () const | |||||||||
The address to use on the "to" attribute of the stream:stream. | ||||||||||
void | SetPort (int Port) | |||||||||
Automatically send presence on connection. | ||||||||||
int | GetPort () const | |||||||||
The TCP port to connect to. | ||||||||||
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. | ||||||||||
float | GetKeepAlive () const | |||||||||
Time, in seconds, between keep-alive spaces. | ||||||||||
void | SetAutoReconnect (float AutoReconnect) | |||||||||
Seconds before automatically reconnecting if the connection drops. | ||||||||||
float | GetAutoReconnect () const | |||||||||
Seconds before automatically reconnecting if the connection drops. | ||||||||||
const char * | GetServerVersion () const | |||||||||
The version string returned in the server's open stream element. | ||||||||||
void | SetRequiresSASL (bool RequiresSASL) | |||||||||
Is SASL required? This will default to true in the future. | ||||||||||
bool | GetRequiresSASL () const | |||||||||
Is SASL required? This will default to true in the future. | ||||||||||
bool | Connect () | |||||||||
Connect to the server. | ||||||||||
void | Close () | |||||||||
Close down the connection, as gracefully as possible. | ||||||||||
void | 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. | ||||||||||
bool | WriteNPLMessage (const char *to, const char *neuronfile, const char *sCode) | |||||||||
Send a NPL message. | ||||||||||
bool | WriteRawString (const char *rawstring) | |||||||||
Send raw string. | ||||||||||
bool | Login () | |||||||||
Initiate the auth process. | ||||||||||
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
| ||||||||||
void | GetRoster () | |||||||||
Request a new copy of the roster. | ||||||||||
bool | Subscribe (const char *to, const char *nickname, const char *groups) | |||||||||
in Jabber, a contact list is called a roster / Send a presence subscription request and update the roster for a new roster contact. | ||||||||||
void | RemoveRosterItem (const char *to) | |||||||||
in Jabber, a contact list is called a roster / Remove an item from the roster. | ||||||||||
bool | AllowSubscription (const char *to, bool bAllow) | |||||||||
this function is called in OnSubscription method to confirm or refuse a subscription request from another user. | ||||||||||
void | GetAgents () | |||||||||
Request a list of agents from the server. | ||||||||||
bool | Register (const char *jid) | |||||||||
Attempt to register a new user. | ||||||||||
const char * | GetRosterItemDetail (const char *jid) | |||||||||
Retrieve details of a given roster item. | ||||||||||
const char * | GetRosterGroups () | |||||||||
The group names for the roster as a string. | ||||||||||
const char * | GetRosterItems () | |||||||||
The Roster Item names as a string. | ||||||||||
void | AddEventListener (int nListenerType, const char *callbackScript) | |||||||||
add a NPL call back script to a given even listener | ||||||||||
void | RemoveEventListener (int nListenerType, const char *callbackScript) | |||||||||
remove a NPL call back script from a given even listener | ||||||||||
void | ClearEventListener (int nListenerType) | |||||||||
clear all NPL call back script from a given even listener | ||||||||||
void | ResetAllEventListeners () | |||||||||
clear all registered event listeners | ||||||||||
Public Attributes | ||||||||||
::ParaEngine::INPLJabberClient * | m_pProxy |
bool ParaScripting::NPLJabberClient::IsValid | ( | ) |
check if object is invalid.
void ParaScripting::NPLJabberClient::SetUser | ( | const char * | User | ) |
The username to connect as.
const char * ParaScripting::NPLJabberClient::GetUser | ( | ) | const |
The username to connect as.
void ParaScripting::NPLJabberClient::SetPriority | ( | int | nPriority | ) |
Priority for this connection.
int ParaScripting::NPLJabberClient::GetPriority | ( | ) | const |
Priority for this connection.
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.
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.
void ParaScripting::NPLJabberClient::SetAutoLogin | ( | bool | AutoLogin | ) |
Automatically log in on connection.
bool ParaScripting::NPLJabberClient::GetAutoLogin | ( | ) | const |
Automatically log in on connection.
void ParaScripting::NPLJabberClient::SetAutoRoster | ( | bool | AutoRoster | ) |
Automatically retrieve roster on connection.
bool ParaScripting::NPLJabberClient::GetAutoRoster | ( | ) | const |
Automatically retrieve roster on connection.
void ParaScripting::NPLJabberClient::SetAutoIQErrors | ( | bool | AutoIQErrors | ) |
Automatically send back 501/feature-not-implemented to IQs that have not been handled.
bool ParaScripting::NPLJabberClient::GetAutoIQErrors | ( | ) | const |
Automatically send back 501/feature-not-implemented to IQs that have not been handled.
void ParaScripting::NPLJabberClient::SetAutoPresence | ( | bool | AutoPresence | ) |
Automatically send presence on connection.
bool ParaScripting::NPLJabberClient::GetAutoPresence | ( | ) | const |
Automatically send presence on connection.
void ParaScripting::NPLJabberClient::SetResource | ( | const char * | Resource | ) |
The connecting resource.
Used to identify a unique connection.
const char * ParaScripting::NPLJabberClient::GetResource | ( | ) | const |
The connecting resource.
Used to identify a unique connection.
void ParaScripting::NPLJabberClient::SetServer | ( | const char * | Server | ) |
The name of the server to connect to.
const char * ParaScripting::NPLJabberClient::GetServer | ( | ) | const |
The name of the server to connect to.
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.
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.
void ParaScripting::NPLJabberClient::SetPort | ( | int | Port | ) |
Automatically send presence on connection.
int ParaScripting::NPLJabberClient::GetPort | ( | ) | const |
The TCP port to connect to.
default to 5222
void ParaScripting::NPLJabberClient::SetKeepAlive | ( | float | KeepAlive | ) |
Time, in seconds, between keep-alive spaces.
default to 20f
float ParaScripting::NPLJabberClient::GetKeepAlive | ( | ) | const |
Time, in seconds, between keep-alive spaces.
default to 20f
void ParaScripting::NPLJabberClient::SetAutoReconnect | ( | float | AutoReconnect | ) |
Seconds before automatically reconnecting if the connection drops.
-1 to disable, 0 for immediate. Default to 30 seconds
float ParaScripting::NPLJabberClient::GetAutoReconnect | ( | ) | const |
Seconds before automatically reconnecting if the connection drops.
-1 to disable, 0 for immediate. Default to 30 seconds
const char * ParaScripting::NPLJabberClient::GetServerVersion | ( | ) | const |
The version string returned in the server's open stream element.
void ParaScripting::NPLJabberClient::SetRequiresSASL | ( | bool | RequiresSASL | ) |
Is SASL required? This will default to true in the future.
bool ParaScripting::NPLJabberClient::GetRequiresSASL | ( | ) | const |
Is SASL required? This will default to true in the future.
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.
void ParaScripting::NPLJabberClient::Close | ( | ) |
Close down the connection, as gracefully as possible.
void 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. |
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. |
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.
bool ParaScripting::NPLJabberClient::Login | ( | ) |
Initiate the auth process.
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. |
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. |
void ParaScripting::NPLJabberClient::GetRoster | ( | ) |
Request a new copy of the roster.
bool ParaScripting::NPLJabberClient::Subscribe | ( | const char * | to, | |
const char * | nickname, | |||
const char * | groups | |||
) |
in Jabber, a contact list is called a roster / Send a presence subscription request and update the roster for a new roster contact.
/
to | The JID of the contact (required) |
nickname | The nickname to show for the user. |
groups | A list of groups to put the contact in. Groups are separated by ';'. May be null. Hint: "foo;bar;" or "foo" |
void ParaScripting::NPLJabberClient::RemoveRosterItem | ( | const char * | to | ) |
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 |
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 |
bool ParaScripting::NPLJabberClient::Register | ( | const char * | jid | ) |
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 |
const char * ParaScripting::NPLJabberClient::GetRosterItemDetail | ( | const char * | jid | ) |
Retrieve details of a given roster item.
jid |
const char * ParaScripting::NPLJabberClient::GetRosterGroups | ( | ) |
The group names for the roster as a string.
each group name is separated by ; such as "general;friends;relatives;"
const char * ParaScripting::NPLJabberClient::GetRosterItems | ( | ) |
The Roster Item names as a string.
each name is separated by ; such as "Xizhi;Andy;Clayman;"
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_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::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_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::ClearEventListener | ( | int | nListenerType | ) |
void ParaScripting::NPLJabberClient::ResetAllEventListeners | ( | ) |
clear all registered event listeners