From 8d0911ac23835568b2f3f2fcfd13f6396d7f3bcd Mon Sep 17 00:00:00 2001 From: Sua Yoo Date: Fri, 11 Dec 2020 15:15:23 -0800 Subject: [PATCH 1/8] simplify and standardize readme --- README.md | 2 +- packages/js/README.md | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3fe256af..65e50bd6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Enable [Telnyx real-time communication](https://developers.telnyx.com/docs/v2/we | Project | Description | README | CHANGELOG | Version | | ---------------- | ---------------------------- | ---------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------- | -| **@telnyx/webrtc** | Telnyx in the browser | [`README`](packages/js#telnyx-webrtc-sdk) | [`CHANGELOG`](packages/js/CHANGELOG.md) | ![NPM](https://img.shields.io/npm/v/@telnyx/webrtc.svg?color=brightgreen) | +| **@telnyx/webrtc** | Telnyx in the browser | [`README`](packages/js#telnyxwebrtc) | [`CHANGELOG`](packages/js/CHANGELOG.md) | ![NPM](https://img.shields.io/npm/v/@telnyx/webrtc.svg?color=brightgreen) | | **@telnyx/react-client** | React wrapper for TelnyxRTC | [`README`](packages/react-client#telnyxreact-client) | [`CHANGELOG`](packages/react-client/CHANGELOG.md) | ![NPM](https://img.shields.io/npm/v/@telnyx/react-client.svg?color=brightgreen) | | **@telnyx/react-native** | React Native wrapper for TelnyxRTC| [`README`](packages/react-native#telnyx-react-native) | [`CHANGELOG`](packages/react-native/CHANGELOG.md) | ![NPM](https://img.shields.io/npm/v/@telnyx/react-native.svg?color=brightgreen) | diff --git a/packages/js/README.md b/packages/js/README.md index 401e0203..b00a19e4 100644 --- a/packages/js/README.md +++ b/packages/js/README.md @@ -1,25 +1,14 @@ -# Telnyx WebRTC SDK +# @telnyx/webrtc ![npm (scoped)](https://img.shields.io/npm/v/@telnyx/webrtc) [![Chromium version](https://img.shields.io/badge/chromium-82.0.4057.0-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-72-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-13.0.4-blue.svg?logo=safari)](https://webkit.org/) [![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://joinslack.telnyx.com/) -The Telnyx WebRTC SDK provides all the functionality you need to start making voice calls from a browser to phone numbers or other browsers. - -[v2 CHANGELOG](CHANGELOG.md) - -To access v1, click [here](https://github.com/team-telnyx/webrtc/tree/v1.0.9) +The Telnyx WebRTC Client provides all the functionality you need to start making voice & video calls from a browser. --- -## Our packages - -- `@telnyx/webrtc` -- `@telnyx/react-native` - [React Native](https://www.npmjs.com/package/@telnyx/react-native) - ## Requirements -You'll need node v11.15.0 or later. - -You'll also need a Telnyx account in order to authenticate your application. Follow our [WebRTC quickstart guide](https://developers.telnyx.com/docs/v2/webrtc/quickstart) to setup your account. +You'll need a Telnyx account in order to authenticate your application. Follow our [WebRTC quickstart guide](https://developers.telnyx.com/docs/v2/webrtc/quickstart) to setup your account. ## Installation @@ -207,7 +196,7 @@ call.hangup(); ### Vanilla Javascript -We've included a few [examples in Javascript(ES6)](https://github.com/team-telnyx/webrtc/tree/main/packages/js/examples/vanilla) to help you get started. +We've included a few [examples in Javascript (ES6)](https://github.com/team-telnyx/webrtc/tree/main/packages/js/examples/vanilla) to help you get started. ``` cd examples/vanilla @@ -223,6 +212,11 @@ Screenshot: We've included a few [examples in React](https://github.com/team-telnyx/webrtc/tree/main/packages/js/examples) to help you get started. This library is not limited to React and can be used with any JavaScript framework of your choosing. +> _Looking for an easier way to get started with React or React Native? Check out our other packages:_ +> +> - [@telnyx/react-client](../react-client) +> - [@telnyx/react-native](../react-client) + #### Audio call ``` @@ -249,7 +243,9 @@ npm start Screenshot: ![Web Dialer](https://raw.githubusercontent.com/team-telnyx/webrtc/master/packages/js/examples/react-video/react-video-screenshot.png) -### Development +--- + +## Development This library is written in [TypeScript](https://www.typescriptlang.org/) to define a clear API with optional typechecking benefits. @@ -273,6 +269,10 @@ To generate TypeScript documentation: npm run docs ``` +### Requirements + +You'll need node v11.15.0 or later. + --- ## Contributing From 264ebb9c13ae5c591d6cb2580b3baf67a23ba348 Mon Sep 17 00:00:00 2001 From: Sua Yoo Date: Fri, 11 Dec 2020 16:09:12 -0800 Subject: [PATCH 2/8] cross link readme to docs --- packages/js/README.md | 190 ++++++++++++----------------------- packages/js/src/TelnyxRTC.ts | 9 +- 2 files changed, 70 insertions(+), 129 deletions(-) diff --git a/packages/js/README.md b/packages/js/README.md index b00a19e4..92aa3844 100644 --- a/packages/js/README.md +++ b/packages/js/README.md @@ -26,169 +26,107 @@ import { TelnyxRTC } from '@telnyx/webrtc'; ## Usage -To initialize the WebRTC client, you'll need to authenticate using a Telnyx SIP Connection. Follow our [quickstart guide](https://developers.telnyx.com/docs/v2/webrtc/quickstart) to learn how to use our APIs to create **JWTs** (JSON Web Tokens) to authenticate. You can also [create a Credential Connection](https://developers.telnyx.com/docs/v2/sip-trunking/quickstarts/portal-setup) and authenticate with its `username` and `password`. - -To use the `ringbackFile`, make sure the "Generate Ringback Tone" option is **disabled** in your [Telnyx Portal connection](https://portaldev.telnyx.com/#/app/connections) configuration (Inbound tab.) +To initialize the WebRTC client, you'll need to authenticate using a Telnyx SIP Connection. Follow our [quickstart guide](https://developers.telnyx.com/docs/v2/webrtc/quickstart) to create **JWTs** (JSON Web Tokens) to authenticate. You can also authenticate directly with the SIP Connection `username` and `password`. ```js // Initialize the client const client = new TelnyxRTC({ - /* - Use a JWT to authenticate (recommended) - */ + /* Use a JWT to authenticate (recommended) */ login_token: login_token, - /* - or use your Connection credentials - */ - login: username, - password: password, - /* - ringtoneFile - This file can be a wav/mp3 in your local public folder or you can host it in a CDN and pass just the URL, such as https://cdn.company.com/sounds/call.mp3 - */ - ringtoneFile: './sounds/incoming_call.mp3', - /* - ringbackFile - Used when you disable Generate Ringback Tone to provide your own ringback sound. - */ - ringbackFile: './sounds/ringback_tone.mp3', + /* or use your Connection credentials */ + // login: username, + // password: password, }); +// Connect and login +client.connect(); + +// You can disconnect when you're done +// client.disconnect(); +``` + +> See [TelnyxRTC#constructor](./docs/ts/classes/telnyxrtc.md#constructors) for all options. + +Important: You should treat Connection credentials as sensitive data and should not hardcode credentials into your frontend web application. Check out the [examples](https://github.com/team-telnyx/webrtc/tree/main/examples/react) for sample React code that handles username and password by prompting the user. + +To hear/view calls in the browser, you'll need to specify an HTML media element: + +```js +client.remoteElement = 'remoteMedia'; +``` + +The corresponding HTML: + +```html +