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.
For anyone looking to get involved to this project, we are glad to hear from you. Here are a few types of contributions that we would be interested in hearing about.
4
+
5
+
* Bug fixes
6
+
- If you find a bug, please first report it using Github Issues.
7
+
- Issues that have already been identified as a bug will be labelled `bug`.
8
+
- If you'd like to submit a fix for a bug, send a Pull Request from your own fork and mention the Issue number.
9
+
+ Include a test that isolates the bug and verifies that it was fixed.
10
+
* New Features
11
+
- If you'd like to accomplish something in the library that it doesn't already do, describe the problem in a new Github Issue.
12
+
- Issues that have been identified as a feature request will be labelled `enhancement`.
13
+
- If you'd like to implement the new feature, please wait for feedback from the project maintainers before spending too much time writing the code. In some cases, `enhancement`s may not align well with the project objectives at the time.
14
+
* Tests, Documentation, Miscellaneous
15
+
- If you think the test coverage could be improved, the documentation could be clearer, you've got an alternative implementation of something that may have more advantages, or any other change we would still be glad hear about it.
16
+
- If its a trivial change, go ahead and send a Pull Request with the changes you have in mind
17
+
- If not, open a Github Issue to discuss the idea first.
18
+
19
+
## Requirements
20
+
21
+
For a contribution to be accepted:
22
+
23
+
* The test suite must be complete and pass
24
+
* Code must follow existing styling conventions
25
+
* Commit messages must be descriptive. Related issues should be mentioned by number.
26
+
27
+
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.
28
+
29
+
## How To
30
+
31
+
1. Fork this repository on GitHub.
32
+
1. Clone/fetch your fork to your local development machine.
33
+
1. Create a new branch (e.g. `issue-12`, `feat/add_foo`, etc) and check it out.
34
+
1. Make your changes and commit them. (Did the tests pass?)
35
+
1. Push your new branch to your fork. (e.g. `git push myname issue-12`)
36
+
1. Open a Pull Request from your new branch to the original fork's `dev` branch.
37
+
1. Ensure the Pull Request's automated status checks have all passed and are ready for review.
38
+
39
+
## Code structure
40
+
41
+
Source code is to be placed in the [src](src/) directory and tests in the [test](test/) directory. Test files should be suffixed with `.spec.js` and follow a similar test suite structure to existing test files.
42
+
43
+
All source and test code should follow the same style as existing source and test code and will be enforced by an automated [eslint](http://eslint.org/) style check that runs on every Pull Request.
Alternatively, wrap your top-level component using OpenTok with the [`preloadScript`](#preloadscript-higher-order-component) HOC. The HOC will take care of loading `opentok.js` for you before rendering.
53
+
44
54
## Example App
45
55
46
56
There is an example application provided in `example/` and you can run it with the following steps:
@@ -66,19 +76,13 @@ The following sections explains how to import and use `opentok-react` in your Re
66
76
Import the `opentok-react` components into your React application:
@@ -142,20 +146,37 @@ class MyApp extends React.Component {
142
146
143
147
## API Reference
144
148
145
-
The `opentok-react` library is comprised of:
149
+
The `opentok-react` library comprises of:
146
150
147
151
-`OTSession` Component
148
152
-`OTPublisher` Component
149
153
-`OTStreams` Component
150
154
-`OTSubscriber` Component
151
155
-`createSession` Helper
156
+
-`preloadScript` Higher-Order Component
152
157
153
158
### OTSession Component
154
159
155
-
TODO
160
+
| Prop | Type | Required | Description |
161
+
| --- | --- | --- | --- |
162
+
| apiKey | String | Yes | TokBox API Key
163
+
| sessionId | String | Yes | TokBox Session ID
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
156
168
157
169
### OTPublisher Component
158
170
171
+
| Prop | Type | Required | Description |
172
+
| --- | --- | --- | --- |
173
+
| 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
179
+
159
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.
160
181
161
182
```js
@@ -209,10 +230,23 @@ class MyApp extends React.Component {
209
230
210
231
### OTStreams Component
211
232
212
-
TODO
233
+
| Prop | Type | Required | Description |
234
+
| --- | --- | --- | --- |
235
+
| children | OTSubscriber | Yes | Must only have a single `OTSubscriber` component (or similar component that accepts `session` and `stream` props)
236
+
| 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
+
| 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`
213
238
214
239
### OTSubscriber Component
215
240
241
+
| Prop | Type | Required | Description |
242
+
| --- | --- | --- | --- |
243
+
| session | [Session](https://tokbox.com/developer/sdks/js/reference/Session.html) | No | OpenTok Session instance. This is auto populated by wrapping `OTSubscriber` with `OTStreams`
244
+
| stream | [Stream](https://tokbox.com/developer/sdks/js/reference/Stream.html) | No | OpenTok Stream instance. This is auto populated by wrapping `OTSubscriber` with `OTStreams`
245
+
| properties | Object | No | Properties passed into `session.subscribe`
246
+
| eventHandlers | Object<Function> | No | Event handlers passed into `subscriber.on`
247
+
| onSubscribe | Function() | No | Invoked when `session.subscribe` successfully completes
248
+
| onError | Function(err) | No | Invoked when `session.subscribe` fails
249
+
216
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.
217
251
218
252
```js
@@ -273,6 +307,39 @@ The `createSession` helper returns an object with the following properties:
273
307
274
308
Use of this helper is optional and you can instead use the `OTSession` component or directly call [OT.initSession](https://tokbox.com/developer/sdks/js/reference/OT.html#initSession) and listen to [streamCreated](https://tokbox.com/developer/sdks/js/reference/Session.html#event:streamCreated) events if you prefer.
275
309
310
+
311
+
### `preloadScript` Higher-Order Component
312
+
313
+
| Prop | Type | Required | Description |
314
+
| --- | --- | --- | --- |
315
+
| 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 />`.
317
+
318
+
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
+
320
+
For example, imagine you have a React Router application with the following route structure:
321
+
322
+
```javascript
323
+
<Router>
324
+
<Route path="/">
325
+
<IndexRoute component="..."/>
326
+
<Route path="something" component="..."/>
327
+
<Route path="video" component={VideoChat} />
328
+
<Route path="something-else" component="..."/>
329
+
</Route>
330
+
</Router>
331
+
```
332
+
333
+
What you'd like to do is delay the loading of `opentok.js` until the `VideoChat` component is being used. Here's how you can do this:
@@ -282,6 +349,28 @@ Use of this helper is optional and you can instead use the `OTSession` component
282
349
1.`npm run build`
283
350
1. Check that files in `dist/` have been updated.
284
351
352
+
## Contributing
353
+
354
+
If you make changes to the project that you would like to contribute back then please follow the [contributing guidelines](CONTRIBUTING.md). All contributions are greatly appreciated!
355
+
285
356
## Tests
286
357
287
-
TODO
358
+
Run the unit tests locally with the following command:
359
+
360
+
```
361
+
npm run unit
362
+
```
363
+
364
+
By default this will launch the Chrome browser. To run tests in Firefox use:
365
+
366
+
```
367
+
npm run unit -- --browsers Firefox
368
+
```
369
+
370
+
Run the linter with:
371
+
372
+
```
373
+
npm run lint
374
+
```
375
+
376
+
The unit tests are automatically run on [Travis](https://travis-ci.org/aiham/opentok-react) on both Chrome and Firefox and the current build status is shown at the top of this document.
0 commit comments