You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 25, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,8 @@ For a contribution to be accepted:
22
22
23
23
* The test suite must be complete and pass
24
24
* Code must follow existing styling conventions
25
-
* Commit messages must be descriptive. Related issues should be mentioned by number.
25
+
* Commit messages must be descriptive. Related issues should be mentioned by number
26
+
* If the contribution includes a change to the dependency list then the `yarn.lock` file must be updated
26
27
27
28
If the contribution doesn't meet these criteria, a maintainer will discuss it with you on the Issue. You can still continue to add more commits to the branch you have sent the Pull Request from.
@@ -61,7 +61,7 @@ There is an example application provided in `example/` and you can run it with t
61
61
1. Edit `config.js`:
62
62
1. Add your OpenTok API key, Session ID and Token (https://tokbox.com/account/)
63
63
1. Add your Chrome Extension ID (https://tokbox.com/developer/guides/screen-sharing/js/)
64
-
1.`npm install`
64
+
1.`yarn` (or `npm install`)
65
65
1.`npm run example`
66
66
1. Visit `http://localhost:8000` in your browser
67
67
@@ -162,31 +162,44 @@ The `opentok-react` library comprises of:
162
162
| apiKey | String | Yes | TokBox API Key
163
163
| sessionId | String | Yes | TokBox Session ID
164
164
| token | String | Yes | TokBox token
165
-
| eventHandlers | Object<Function> | No | Event handlers passed into `session.on`
166
-
| onConnect | Function() | No | Invoked when `session.connect` successfully completes
167
-
| onError | Function(err) | No | Invoked when `session.connect` fails
165
+
| eventHandlers | Object<Function> | No | Event handlers passed into [session.on](https://tokbox.com/developer/sdks/js/reference/Session.html#on)
166
+
| onConnect | Function() | No | Invoked when [session.connect](https://tokbox.com/developer/sdks/js/reference/Session.html#connect) successfully completes
167
+
| onError | Function(err) | No | Invoked when [session.connect](https://tokbox.com/developer/sdks/js/reference/Session.html#connect) fails
168
+
169
+
The `OTSession` component manages the connection to an OpenTok [Session](https://tokbox.com/developer/sdks/js/reference/Session.html). It passes the Session instance as the `session` prop to its child components. It is recommended that you nest `OTPublisher` and `OTStreams` inside `OTSession`:
| session | [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) | No | OpenTok Session instance
174
-
| properties | Object | No | Properties passed into `OT.initPublisher`
175
-
| eventHandlers | Object<Function> | No | Event handlers passed into `publisher.on`
176
-
| onInit | Function() | No | Invoked when `OT.initPublisher` successfully completes
177
-
| onPublish | Function() | No | Invoked when `session.publish` successfully completes
178
-
| onError | Function(err) | No | Invoked when either `OT.initPublisher` or `session.publish` fail
184
+
| session | [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) | No | OpenTok Session instance. This is auto populated by wrapping `OTPublisher` with `OTSession`
185
+
| properties | Object | No | Properties passed into [OT.initPublisher](https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher)
186
+
| eventHandlers | Object<Function> | No | Event handlers passed into [publisher.on](https://tokbox.com/developer/sdks/js/reference/Publisher.html#on)
187
+
| onInit | Function() | No | Invoked when [OT.initPublisher](https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher) successfully completes
188
+
| onPublish | Function() | No | Invoked when [session.publish](https://tokbox.com/developer/sdks/js/reference/Session.html#publish) successfully completes
189
+
| onError | Function(err) | No | Invoked when either [OT.initPublisher](https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher) or [session.publish](https://tokbox.com/developer/sdks/js/reference/Session.html#publish) fail
179
190
180
-
The `OTPublisher` component will initialise a publisher and publish to a specified session upon mounting. You must specify a [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) object using the `session` prop.
191
+
The `OTPublisher` component will initialise a publisher and publish to a specified session upon mounting. It will also ensure the Publisher video element is attached to the DOM inside the component rather than appending to the body (which is the Publisher's default behaviour).
If you are not using `OTSession` then you must specify a [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) object using the `session` prop.
Use the `properties` prop to specify a properties object for [OT.initPublisher](https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher) and the `eventHandlers` prop to specify an object of event handlers for [Publisher#on](https://tokbox.com/developer/sdks/js/reference/Publisher.html#on).
@@ -213,26 +226,34 @@ class MyApp extends React.Component {
- Explain which properties `OTPublisher` will monitor for changes.
229
-
- Explain that this component will not cause publisher to be appended to body.
240
+
The `properties` prop is used for initial set up of the Publisher and making changes to it will not update the Publisher, you will instead need to invoke Publisher methods. To facilitate this the Publisher instance is exposed via the `getPublisher()` component method. You should always call this method to get the latest Publisher instance instead of keeping a reference to it as it's possible for the Publisher instance to change, leaving you with a stale reference.
241
+
242
+
However, for convenience the `OTPublisher` does watch for changes on a few keys of the `properties` object and makes the necessary changes. Currently these are:
243
+
244
+
| Publisher Property | Action |
245
+
| --- | --- |
246
+
| videoSource | Destroys and recreates the Publisher with the new video source. This is the only way to change the video source of a Publisher. This is used in the example application to allow the user to toggle between publishing their camera and publishing their screen |
247
+
| publishAudio | Calls [publisher.publishAudio()](https://tokbox.com/developer/sdks/js/reference/Publisher.html#publishAudio) to toggle audio on and off |
248
+
| publishVideo | Calls [publisher.publishVideo()](https://tokbox.com/developer/sdks/js/reference/Publisher.html#publishVideo) to toggle video on and off |
249
+
250
+
There are plans to support more Publisher properties but for now you will have to call `getPublisher()` to retrieve the Publisher instance and make the necessary changes yourself.
230
251
231
252
### OTStreams Component
232
253
233
254
| Prop | Type | Required | Description |
234
255
| --- | --- | --- | --- |
235
-
| children | OTSubscriber | Yes | Must only have a single `OTSubscriber` component (or similar component that accepts `session` and `stream` props)
256
+
| children | ReactElement | Yes | Must have a single child component that accepts `session` and `stream` props, eg. `OTSubscriber`
236
257
| session | [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) | Yes | OpenTok Session instance. This is auto populated by wrapping `OTStreams` with `OTSession`
237
258
| streams | Array<[Stream](https://tokbox.com/developer/sdks/js/reference/Stream.html)> | No | Array of OpenTok Stream instances. This is auto populated by wrapping `OTStreams` with `OTSession`
238
259
@@ -247,34 +268,73 @@ class MyApp extends React.Component {
247
268
| onSubscribe | Function() | No | Invoked when `session.subscribe` successfully completes
248
269
| onError | Function(err) | No | Invoked when `session.subscribe` fails
249
270
250
-
The `OTSubscriber` component will subscribe to a specified stream from a specified session upon mounting. You must provide a [Stream](https://tokbox.com/developer/sdks/js/reference/Stream.html) object using the `stream` prop and a [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) object using the `session` prop.
271
+
The `OTSubscriber` component will subscribe to a specified stream from a specified session upon mounting. It will also ensure the Subscriber video element is attached to the DOM inside the component rather than appending to the body (which is the Subscriber's default behaviour).
272
+
273
+
```html
274
+
<OTStreams>
275
+
<OTSubscriber />
276
+
</OTStreams>
277
+
```
278
+
279
+
If you are not using `OTStreams` then you must provide a [Stream](https://tokbox.com/developer/sdks/js/reference/Stream.html) object using the `stream` prop and a [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) object using the `session` prop.
280
+
281
+
```js
282
+
{this.sessionHelper.streams.map(stream=> (
283
+
<OTSubscriber
284
+
key={stream.id}
285
+
session={this.sessionHelper.session}
286
+
stream={stream}
287
+
/>
288
+
))}
289
+
```
290
+
291
+
Use the `properties` prop to specify a properties object for [session.subscribe](https://tokbox.com/developer/sdks/js/reference/Session.html#subscribe) and the `eventHandlers` prop to specify an object of event handlers for [Subscriber#on](https://tokbox.com/developer/sdks/js/reference/Subscriber.html#on).
- Explain which properties `OTPublisher` will monitor for changes.
277
-
- Explain that this component will not cause subscriber to be appended to body.
328
+
The `properties` prop is used for initial set up of the Subscriber and making changes to it will not update the Subscriber, you will instead need to invoke Subscriber methods. To facilitate this the Subscriber instance is exposed via the `getSubscriber()` component method. You should always call this method to get the latest Subscriber instance instead of keeping a reference to it as it's possible for the Subscriber instance to change, leaving you with a stale reference.
329
+
330
+
However, for convenience the `OTSubscriber` does watch for changes on a few keys of the `properties` object and makes the necessary changes. Currently these are:
331
+
332
+
| Subscriber Property | Action |
333
+
| --- | --- |
334
+
| subscribeToAudio | Calls [subscriber.subscribeToAudio()](https://tokbox.com/developer/sdks/js/reference/Subscriber.html#subscribeToAudio) to toggle audio on and off |
335
+
| subscribeToVideo | Calls [subscriber.subscribeToVideo()](https://tokbox.com/developer/sdks/js/reference/Subscriber.html#subscribeToVideo) to toggle video on and off |
336
+
337
+
There are plans to support more Subscriber properties but for now you will have to call `getSubscriber()` to retrieve the Subscriber instance and make the necessary changes yourself.
278
338
279
339
### createSession Helper
280
340
@@ -313,13 +373,13 @@ Use of this helper is optional and you can instead use the `OTSession` component
313
373
| Prop | Type | Required | Description |
314
374
| --- | --- | --- | --- |
315
375
| opentokClientUrl | String | No | The URL of the OpenTok client script to load. It defaults to `https://static.opentok.com/v2/js/opentok.min.js`.
316
-
| loadingDelegate | Element | No | An element that will be displayed while the OpenTok client script is loading. It defaults to an empty `<div />`.
376
+
| loadingDelegate | ReactElement | No | An element that will be displayed while the OpenTok client script is loading. It defaults to an empty `<div />`.
317
377
318
378
In larger applications, one might not want to load the `opentok.js` client with a `<script>` tag all the time. The `preloadScript` higher-order component will do this for you at the appropriate time.
319
379
320
380
For example, imagine you have a React Router application with the following route structure:
0 commit comments