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. String representing a destination username or a complete SIP URI.
body
Message content. String representing the body of the message.
contentType
Optional String representing the content-type of the body. Default text/plain.
options
Optional Object with extra parameters (see below).

Fields in options Object

extraHeaders
Array of Strings with 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).
request
JsSIP.OutgoingRequest instance 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.
response
JsSIP.IncomingResponse instance 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.
response
JsSIP.IncomingResponse instance generating the failure for originator value of remote, null otherwise.
cause
One value of Failure and End Causes.