Represents the software phone running in a web browser or other context.
Kind: global class
- TelnyxDevice
- new TelnyxDevice(config)
- .startWS()
- .stopWS()
- .isWSConnected() ⇒
Boolean
- .register(options)
- .unregister(options)
- .isRegistered() ⇒
Boolean
- .initiateCall(phoneNumber) ⇒
TelnyxCall
- .activeCall() ⇒
TelnyxCall
- "wsConnecting"
- "wsConnected"
- "wsDisconnected"
- "registered"
- "unregistered"
- "registrationFailed"
- "invite"
- "message"
Create a new TelnyxDevice.
Param | Type | Description |
---|---|---|
config | Object |
Configuration Object |
config.host | String |
The host name or IP address of the SIP server |
config.port | String |
The port of the SIP server |
config.wsServers | String |
URI(s) of the WebSocket Servers. Format wss://123.0.0.0:5066 . An array of strings is also accepted. |
config.username | String |
The username for the SIP server |
config.password | String |
The passweord for the SIP server |
config.displayName | String |
The human readable name passed in the from field. Will be used for Caller ID |
config.stunServers | String |
URI(s) for how to connect to the STUN servers. Format stun:stun.telnyx.com:8000 . An array of strings is also accepted. |
config.turnServers | Object |
Details for how to connect to the TURN servers. An array of objects is also accepted. |
config.turnServers.urls | String |
URI(s) for the TURN server(s). Format turn:turn.telnyx.com:8000?transport=tcp . An array of strings is also accepted. |
config.turnServers.username | String |
Username to authenticate on TURN server(s) |
config.turnServers.password | String |
Password to authenticate on TURN server(s) |
config.registrarServer | String |
URI for the registrar Server. Format sip:123.0.0.0:5066 |
config.traceSip | Boolean |
If true, SIP traces will be logged to the dev console. |
config.logLevel | String |
One of "debug", "log", "warn", "error", "off". default is "log" |
Start the connection to the WebSocket server, and restore the previous state if stopped.
You need to start the WebSocket connection before you can send or recieve calls. If you
try to initiateCall
without first starting the connection, it will be started for you,
but it will not be stopped when the call is terminated.
Kind: instance method of TelnyxDevice
Stop the connection to the WebSocket server, saving the state so it can be restored later
(by start
).
Kind: instance method of TelnyxDevice
Status of the WebSocket connection
Kind: instance method of TelnyxDevice
Returns: Boolean
- isConnected true
if the device is connected to the WebSocket server, false
otherwise
Register the device with the SIP server so that it can receive incoming calls.
Kind: instance method of TelnyxDevice
Emits: registered
Param | Type | Description |
---|---|---|
options | Object |
|
options.extraHeaders | Array.<String> |
SIP headers that will be added to each REGISTER request. Each header is string in the format "X-Header-Name: Header-value" . |
Unregister the device from the SIP server; it will no longer recieve incoming calls.
Kind: instance method of TelnyxDevice
Emits: unregistered
Param | Type | Description |
---|---|---|
options | Object |
|
options.all | Boolean |
[Optional] - if set & true it will unregister all bindings for the SIP user. |
options.extraHeaders | Array.<String> |
SIP headers that will be added to each REGISTER request. Each header is string in the format "X-Header-Name: Header-value" . |
Status of SIP registration
Kind: instance method of TelnyxDevice
Returns: Boolean
- isRegistered true
if the device is registered with the SIP Server, false
otherwise
Make a phone call
Kind: instance method of TelnyxDevice
Returns: TelnyxCall
- activeCall Keep an eye on the call's state by listening to events emitted by activeCall
Param | Type | Description |
---|---|---|
phoneNumber | String |
The desination phone number to connect to. Just digits, no punctuation. Example "12065551111" . |
Get a reference to the call currently in progress
Kind: instance method of TelnyxDevice
Returns: TelnyxCall
- activeCall Keep an eye on the call's state by listening to events emitted by activeCall
wsConnecting event
Fired when the device attempts to connect to the WebSocket server. If the connection drops, the device will try to reconnect and this event will fire again.
Kind: event emitted by TelnyxDevice
Properties
Name | Type | Description |
---|---|---|
attempts | number |
the number of connection attempts that have been made |
wsConnected event
Fired when the WebSocket connection has been established.
Kind: event emitted by TelnyxDevice
wsDisconnected event
Fried when the WebSocket connection attempt fails.
Kind: event emitted by TelnyxDevice
registered event
Fired when a the device has been successfully registered to recieve calls.
Kind: event emitted by TelnyxDevice
unregistered event
Fired as the result of a call to unregister()
or if a periodic re-registration fails.
Kind: event emitted by TelnyxDevice
Properties
Name | Type | Description |
---|---|---|
cause | object |
null if unregister() was called, otherwise see SIPjs causes |
response | object |
The SIP message which caused the failure, if it exists. |
registrationFailed event
Fired when a registration attepmt fails.
Kind: event emitted by TelnyxDevice
Properties
Name | Type | Description |
---|---|---|
cause | object |
see SIPjs causes |
response | object |
The SIP message which caused the failure, if it exists. |
incomingInvite event
Fired when the device recieves an INVITE request
Kind: event emitted by TelnyxDevice
message event
Kind: event emitted by TelnyxDevice
Properties
Name | Type | Description |
---|---|---|
message | object |
Contains the SIP message sent and server context necessary to receive and send replies. |