SendMessage Method
This method will send a message to the specified user.
Syntax
xmpp.sendMessage(jabberId, [callback])
Callback
The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).
The callback for this method is defined as:
function(err, data){ }
'err' is the error that occurred. If there was no error, then 'err' is 'null'.
'data' is the value returned by the method.
'err' has 2 properties which hold detailed information:
err.code err.message
Remarks
JabberId is the intended recipient of the message. It is of the form user@domain/resource. If a resource is not supplied, all logged-in instances of the user's account will receive the message.
The class associates several properties with messages it receives and sends. When it receives a message, the class will parse out the corresponding values and set these properties before firing a MessageIn event. After the event returns control to the class, the properties will be cleared (ie, they will be set to the empty string, "").
Before sending a message, the application should set the appropriate properties to be associated with the message. The class will send only properties with non-empty string values (""), and will clear all properties after a successful send.
The associated properties are the following:
MessageType | the type of the message to be sent |
MessageSubject | for "headline" type messages, this is the subject |
MessageThread | for "chat" type messages, this is the thread on which the current message is a follow-up |
MessageText | the plain text of the message |
MessageHTML | the HTML version of the message |
MessageOtherData | any extra data associated with the message but not required by the protocol. |
If the parameter passed to SendMessage is prefixed with "@" the component will interpret the value as a domain when constructing the message. This allows for sending directly to sub-domains.
Note: the XMPP class will generate and return a unique identifier for each message sent. This identifier can be used to track messages in conjunction with various Jabber Extension Protocols.