Class JsSIP.Message
SIP MESSAGE based IM.
Instance Methods
send(target, body, contentType="text/plain", options=null)
Sends the message through the WebSocket connection. This method is available for outgoing messages only.
Parameters
target- Destination of the message.
Stringrepresenting a destination username or a complete SIP URI. body- Message content.
Stringrepresenting the body of the message. contentType- Optional
Stringrepresenting the content-type of the body. Defaulttext/plain. options- Optional
Objectwith extra parameters (see below).
Fields in options Object
extraHeadersArrayofStringswith extra SIP headers for the MESSAGE request.
Throws
Example
var contentType = "text/plain";
var text = 'Hello Bob!';
var options = {
extraHeaders: [ 'X-Foo: foo', 'X-Bar: bar' ]
};
var message = new JsSIP.Message(coolPhone);
message.on('succeeded', function(e){ // Your code here });
message.on('failed', function(e){ // Your code here });
message.send('sip:bob@example.com', text, contentType, options);
Events
JsSIP.Message class defines a series of events. Each of them allows callback functions registration in order to let the user execute a handler for each given stimulus.
Every event handler is executed with a JsSIP.Event instance as the only argument.
sending
Fired when the MESSAGE request is created, before sending through the WebSocket connection and after firing UA.newMessage event.
Event data fields
originator- ‘local’
String(local user generated the MESSAGE). requestJsSIP.OutgoingRequestinstance of the generated MESSAGE request.
succeeded
Fired when receiving a final positive response to MESSAGE request.
Event data fields
originator- ‘remote’
String. Remote peer responded positively to the SIP MESSAGE. responseJsSIP.IncomingResponseinstance of the received 2XX response.
failed
Fired if no final positive response for the sent MESSAGE is received.
Event data fields
originator- ‘remote’/‘system’
String. Where does the MESSAGE failure come from. responseJsSIP.IncomingResponseinstance generating the failure for originator value ofremote, null otherwise.cause- One value of Failure and End Causes.