A stand alone JS API for Telnyx's WebRTC offering. Our goal is to provide an API for Telnyx WebRTC that is as simple as possible, but no simpler. We hide as much of the gorey, low level SIP and auth details as we can, while still providing enough detail to build a beautiful and responsive phone UI.
Under the covers we use SIP.JS, but that is merely an implementation detail. It is bundled in the distributed file.
You'll need to get set up to use the @telnyx npm registry before you start.
$ npm install --save @telnyx/rtc
or
$ yarn add @telnyx/rtc
In Telnyx webpack built projects you'll need to require the library:
require("script!../../node_modules/@telnyx/rtc/dist/telnyx-rtc.js");
Then import TelnyxDevice in the module where you need it.
import { TelnyxDevice } from "@telnyx/rtc";
let config = {
host: "sip.telnyx.com",
port: "7443",
wsServers: "wss://sip.telnyx.com:7443",
displayName: "Phone User",
username: "testuser",
password: "testuserPassword",
stunServers: "stun:stun.telnyx.com:3843",
turnServers: {
urls: ["turn:turn.telnyx.com:3478?transport=tcp"],
username: "turnuser",
password: "turnpassword"
},
registrarServer: "sip:sip.telnyx.com:7443"
};
let device = new TelnyxDevice(config);
let activeCall = device.initiateCall("1235556789");
activeCall.on("connecting", () => {console.log("it's connecting!")});
activeCall.on("accepted", () => {console.log("We're on a phone call!")});
See the TelnyxDevice and TelnyxCall for more details.
Sometimes you need to test your UI without making phone calls all the time. See @telnyx/rtc-mocks.
When working on the package directly, please use yarn instead of npm.
$ yarn run build
Use @telnyx/npm-release to manage versions.
$ yarn run test
We use jsdoc-to-markdown to generate github friendly docs.
$ yarn run docs