API
SIP.ClientContext
A SIP.ClientContext
encapsulates the behavior required to send a request, as well as handle responses and retransmissions of that request. It is typically mixed in with behavior from a method-specific class, such as SIP.Session
or SIP.Message
.
Instance Attributes
ua
SIP.UA
- The user agent from which the request was sent or will be sent.
method
String
- The SIP method of the request. For example, "INVITE"
or "MESSAGE"
.
request
SIP.OutgoingRequest
- The request sent or to be sent.
localIdentity
SIP.NameAddrHeader
- The From header field value, representing the local endpoint. This is typically the URI of the UA as a SIP.NameAddrHeader
.
remoteIdentity
SIP.NameAddrHeader
- The To header field value, representing the remote endpoint.
data
Object
- An empty object. Define custom application data here. Note: SIP.js may overwrite any custom attributes defined outside of the data object.
Instance Methods
cancel([options])
Send a CANCEL before the original request has been accepted.
Parameters
Name | Type | Description |
---|---|---|
options |
Object |
Optional Object with extra parameters (see below). |
options.statusCode |
Number |
The SIP response code that will be used in the upcoming response instead of the default. |
options.reasonPhrase |
String |
The SIP reason phrase. |
Returns
Type | Description |
---|---|
SIP.ClientContext |
This ClientContext |
Throws
TypeError INVALID_STATE_ERROR
Events
progress
Fired each time a provisional (100-199) response is received.
on('progress', function (response, cause) {})
Name | Type | Description |
---|---|---|
response |
SIP.IncomingMessage |
The received response |
cause |
String |
The SIP cause of the event |
accepted
Fired each time a successful final (200-299) response is received.
on('accepted', function (response, cause) {})
Name | Type | Description |
---|---|---|
response |
SIP.IncomingMessage |
The received response |
cause |
String |
The SIP cause of the event |
rejected
Fired each time an unsuccessful final (300-699) response is received. Note: This will also emit a failed
event.
on('rejected', function (response,cause) {})
Name | Type | Description |
---|---|---|
response |
SIP.IncomingMessage |
The received response |
cause |
String |
The SIP cause of the event |
failed
Fired when the request fails, whether due to an unsuccessful final response or due to timeout, transport, or other error.
on('failed', function (response, cause) {})
Name | Type | Description |
---|---|---|
response |
SIP.IncomingMessage |
The received response, on a non SIP related failure this will be null |
cause |
String |
The SIP cause of the event |