opentok 0.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +16 -2
- data/.travis.yml +6 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +47 -0
- data/DEVELOPING.md +91 -0
- data/LICENSE +19 -5
- data/README.md +170 -53
- data/Rakefile +10 -5
- data/doc/OpenTok.html +411 -0
- data/doc/OpenTok/Archive.html +1320 -0
- data/doc/OpenTok/ArchiveList.html +216 -0
- data/doc/OpenTok/Archives.html +1028 -0
- data/doc/OpenTok/Client.html +695 -0
- data/doc/OpenTok/OpenTok.html +1046 -0
- data/doc/OpenTok/OpenTokArchiveError.html +142 -0
- data/doc/OpenTok/OpenTokAuthenticationError.html +143 -0
- data/doc/OpenTok/OpenTokError.html +138 -0
- data/doc/OpenTok/Session.html +665 -0
- data/doc/OpenTok/TokenGenerator.html +204 -0
- data/doc/OpenTok/TokenGenerator/ClassMethods.html +187 -0
- data/doc/README.md +15 -0
- data/doc/_index.html +182 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +87 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +87 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +227 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/opentok.rb +3 -14
- data/lib/opentok/archive.rb +92 -0
- data/lib/opentok/archive_list.rb +17 -0
- data/lib/opentok/archives.rb +120 -0
- data/lib/opentok/client.rb +125 -0
- data/lib/opentok/constants.rb +5 -0
- data/lib/opentok/exceptions.rb +10 -0
- data/lib/opentok/opentok.rb +174 -0
- data/lib/opentok/session.rb +76 -0
- data/lib/opentok/token_generator.rb +101 -0
- data/lib/opentok/version.rb +4 -0
- data/opentok.gemspec +29 -22
- data/sample/Archiving/Gemfile +4 -0
- data/sample/Archiving/README.md +212 -0
- data/sample/Archiving/archiving_sample.rb +80 -0
- data/sample/Archiving/public/css/sample.css +22 -0
- data/sample/Archiving/public/img/archiving-off.png +0 -0
- data/sample/Archiving/public/img/archiving-on-idle.png +0 -0
- data/sample/Archiving/public/img/archiving-on-message.png +0 -0
- data/sample/Archiving/public/js/host.js +37 -0
- data/sample/Archiving/public/js/participant.js +13 -0
- data/sample/Archiving/views/history.erb +65 -0
- data/sample/Archiving/views/host.erb +69 -0
- data/sample/Archiving/views/index.erb +48 -0
- data/sample/Archiving/views/layout.erb +29 -0
- data/sample/Archiving/views/participant.erb +55 -0
- data/sample/HelloWorld/Gemfile +4 -0
- data/sample/HelloWorld/README.md +123 -0
- data/sample/HelloWorld/hello_world.rb +27 -0
- data/sample/HelloWorld/public/js/helloworld.js +32 -0
- data/sample/HelloWorld/views/index.erb +21 -0
- data/spec/cassettes/OpenTok_Archives/should_create_archives.yml +48 -0
- data/spec/cassettes/OpenTok_Archives/should_create_named_archives.yml +49 -0
- data/spec/cassettes/OpenTok_Archives/should_delete_an_archive_by_id.yml +32 -0
- data/spec/cassettes/OpenTok_Archives/should_find_archives_by_id.yml +46 -0
- data/spec/cassettes/OpenTok_Archives/should_stop_archives.yml +48 -0
- data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_all_archives.yml +104 -0
- data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_archives_with_an_offset.yml +71 -0
- data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_count_number_of_archives.yml +60 -0
- data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_part_of_the_archives_when_using_offset_and_count.yml +82 -0
- data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_default_sessions.yml +39 -0
- data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions.yml +39 -0
- data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_with_a_location_hint.yml +39 -0
- data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions.yml +39 -0
- data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_for_invalid_media_modes.yml +39 -0
- data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_with_a_location_hint.yml +39 -0
- data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_sessions_with_a_location_hint.yml +39 -0
- data/spec/matchers/token.rb +48 -0
- data/spec/opentok/archives_spec.rb +91 -0
- data/spec/opentok/opentok_spec.rb +144 -0
- data/spec/opentok/session_spec.rb +71 -0
- data/spec/shared/opentok_generates_tokens.rb +62 -0
- data/spec/shared/session_generates_tokens.rb +63 -0
- data/spec/spec_helper.rb +6 -7
- metadata +197 -59
- data/.rspec +0 -3
- data/CHANGES +0 -33
- data/doc/reference.md +0 -122
- data/lib/open_tok/archive.rb +0 -53
- data/lib/open_tok/archive_timeline_event.rb +0 -22
- data/lib/open_tok/archive_video_resource.rb +0 -28
- data/lib/open_tok/exception.rb +0 -50
- data/lib/open_tok/open_tok_sdk.rb +0 -198
- data/lib/open_tok/request.rb +0 -63
- data/lib/open_tok/role_constants.rb +0 -18
- data/lib/open_tok/session.rb +0 -25
- data/lib/open_tok/session_property_constants.rb +0 -30
- data/lib/open_tok/utils.rb +0 -10
- data/lib/open_tok/version.rb +0 -5
- data/sample/sample.rb +0 -26
- data/spec/cassettes/archives.yml +0 -83
- data/spec/cassettes/deleteArchive.yml +0 -91
- data/spec/cassettes/invalidSession.yml +0 -41
- data/spec/cassettes/session.yml +0 -46
- data/spec/cassettes/stitchArchive.yml +0 -42
- data/spec/opentok_exception_spec.rb +0 -38
- data/spec/opentok_spec.rb +0 -135
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31559c8863e6d4d9fc421175f04ac721510500f7
|
|
4
|
+
data.tar.gz: 7c587bd56bec73b00a1b36250f42c3aefd2bc9a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18227e422d95dfa809324e6ebcd688768ac8fdfec9444039099ac853365492fdf4f362929508030ec7f6cb73d9e998fcd8cdc10836290edd7f5ce9e2ed74bed6
|
|
7
|
+
data.tar.gz: 3d1acb0a2cc1a03cfd8b1bf318c20c5dcca44e363df23cfe3882c2c52d2dfa662886b383c09b35b4fd1022ed99f37c4239751fe418d96e86e0a44751817ff866
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'lib/**/*.rb' --no-private --readme doc/README.md
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Contributing Guidelines
|
|
2
|
+
|
|
3
|
+
For anyone looking to get involved to this project, we are glad to hear from you. Here are a few types of contributions
|
|
4
|
+
that we would be interested in hearing about.
|
|
5
|
+
|
|
6
|
+
* Bug fixes
|
|
7
|
+
- If you find a bug, please first report it using Github Issues.
|
|
8
|
+
- Issues that have already been identified as a bug will be labelled `bug`.
|
|
9
|
+
- If you'd like to submit a fix for a bug, send a Pull Request from your own fork and mention the Issue number.
|
|
10
|
+
+ Include a test that isolates the bug and verifies that it was fixed.
|
|
11
|
+
* New Features
|
|
12
|
+
- If you'd like to accomplish something in the library that it doesn't already do, describe the problem in a new
|
|
13
|
+
Github Issue.
|
|
14
|
+
- Issues that have been identified as a feature request will be labelled `enhancement`.
|
|
15
|
+
- If you'd like to implement the new feature, please wait for feedback from the project maintainers before spending
|
|
16
|
+
too much time writing the code. In some cases, `enhancement`s may not align well with the project objectives at
|
|
17
|
+
the time.
|
|
18
|
+
* Tests, Documentation, Miscellaneous
|
|
19
|
+
- If you think the test coverage could be improved, the documentation could be clearer, you've got an alternative
|
|
20
|
+
implementation of something that may have more advantages, or any other change we would still be glad hear about
|
|
21
|
+
it.
|
|
22
|
+
- If its a trivial change, go ahead and send a Pull Request with the changes you have in mind
|
|
23
|
+
- If not, open a Github Issue to discuss the idea first.
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
For a contribution to be accepted:
|
|
28
|
+
|
|
29
|
+
* The test suite must be complete and pass
|
|
30
|
+
* Code must follow existing styling conventions
|
|
31
|
+
* Commit messages must be descriptive. Related issues should be mentioned by number.
|
|
32
|
+
|
|
33
|
+
If the contribution doesn't meet these criteria, a maintainer will discuss it with you on the Issue. You can still
|
|
34
|
+
continue to add more commits to the branch you have sent the Pull Request from.
|
|
35
|
+
|
|
36
|
+
## How To
|
|
37
|
+
|
|
38
|
+
1. Fork this repository on GitHub.
|
|
39
|
+
1. Clone/fetch your fork to your local development machine.
|
|
40
|
+
1. Create a new branch (e.g. `issue-12`, `feat.add_foo`, etc) and check it out.
|
|
41
|
+
1. Make your changes and commit them. (Did the tests pass?)
|
|
42
|
+
1. Push your new branch to your fork. (e.g. `git push myname issue-12`)
|
|
43
|
+
1. Open a Pull Request from your new branch to the original fork's `master` branch.
|
|
44
|
+
|
|
45
|
+
## Developer Guidelines
|
|
46
|
+
|
|
47
|
+
See DEVELOPING.md for guidelines for developing this project.
|
data/DEVELOPING.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Development Guidelines
|
|
2
|
+
|
|
3
|
+
This document describes tools, tasks and workflow that one needs to be familiar with in order to effectively maintain
|
|
4
|
+
this project. If you use this package within your own software as is but don't plan on modifying it, this guide is
|
|
5
|
+
**not** for you.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
* [Bundler](http://bundler.io): used to ensure gems that are used as dependencies are uniform with other contributors
|
|
10
|
+
and maintainers. The first thing you should do once you've cloned this repository is to run `bundle install`. This
|
|
11
|
+
will also generate the `Gemfile.lock` file, which caches the configuration of gems you are using. Bundler is
|
|
12
|
+
included with all recent versions of Ruby.
|
|
13
|
+
|
|
14
|
+
* [Rake](http://rake.rubyforge.org/): used to run predefined tasks. Rake is usually run by prefixing `bundle exec` to
|
|
15
|
+
ensure that dependencies used for the task are provided through bundler. Example: `$ bundle exec rake spec`. Rake
|
|
16
|
+
is installed by Bundler when `bundler install` is run.
|
|
17
|
+
|
|
18
|
+
## Tasks
|
|
19
|
+
|
|
20
|
+
### Building
|
|
21
|
+
|
|
22
|
+
Building is required to generate the gem. A gem is a distributable artifact suitable for installing on other systems.
|
|
23
|
+
|
|
24
|
+
* `rake build` - builds the gem into the `pkg` directory.
|
|
25
|
+
|
|
26
|
+
### Testing
|
|
27
|
+
|
|
28
|
+
This project's tests are written using [RSpec](http://rspec.info/). It also uses the VCR and WebMock helpers.
|
|
29
|
+
|
|
30
|
+
* `rake spec` - run the test suite.
|
|
31
|
+
|
|
32
|
+
### Generating Documentation
|
|
33
|
+
|
|
34
|
+
This project's reference documentation is generated by Yard and resides in the `docs` directory of the project.
|
|
35
|
+
Common tasks:
|
|
36
|
+
|
|
37
|
+
* `rake yard` - generate the reference documentation.
|
|
38
|
+
|
|
39
|
+
### Releasing
|
|
40
|
+
|
|
41
|
+
In order to create a release, the following should be completed in order.
|
|
42
|
+
|
|
43
|
+
1. Ensure all tests are passing (`rake spec`) and that there is enough test coverage.
|
|
44
|
+
1. Make sure you are on the `master` branch of the repository, with all changes merged/committed already.
|
|
45
|
+
1. Update the version number in the source code (`lib/opentok/version.rb`) and the README. See [Versioning](#versioning) for
|
|
46
|
+
information about selecting an appropriate version number.
|
|
47
|
+
1. Commit the version number change with the message ("Update to version v.x.x.x"), substituting the new version number.
|
|
48
|
+
1. Ensure you have permission to update the `opentok` gem on Rubygems: <https://rubygems.org/gems/opentok>.
|
|
49
|
+
1. Run `rake release`, which will create a git tag for the version number, build, and push the gem to Rubygems.
|
|
50
|
+
1. Change the version number for future development by adding ".alpha.1", then make another commit with the message
|
|
51
|
+
"Beginning development on next version".
|
|
52
|
+
1. Push the changes to the main repository (`git push origin master`).
|
|
53
|
+
|
|
54
|
+
## Workflow
|
|
55
|
+
|
|
56
|
+
### Versioning
|
|
57
|
+
|
|
58
|
+
The project uses [semantic versioning](http://semver.org/) as a policy for incrementing version numbers. For planned
|
|
59
|
+
work that will go into a future version, there should be a Milestone created in the Github Issues named with the version
|
|
60
|
+
number (e.g. "v2.2.1").
|
|
61
|
+
|
|
62
|
+
During development the version number should end in ".alpha.1" or ".beta.x", where x is an increasing number starting
|
|
63
|
+
from 1.
|
|
64
|
+
|
|
65
|
+
### Branches
|
|
66
|
+
|
|
67
|
+
* `master` - the main development branch.
|
|
68
|
+
* `feat.foo` - feature branches. these are used for longer running tasks that cannot be accomplished in one commit.
|
|
69
|
+
once merged into master, these branches should be deleted.
|
|
70
|
+
* `vx.x.x` - if development for a future version/milestone has begun while master is working towards a sooner
|
|
71
|
+
release, this is the naming scheme for that branch. once merged into master, these branches should be deleted.
|
|
72
|
+
|
|
73
|
+
### Tags
|
|
74
|
+
|
|
75
|
+
* `vx.x.x` - commits are tagged with a final version number during release.
|
|
76
|
+
|
|
77
|
+
### Issues
|
|
78
|
+
|
|
79
|
+
Issues are labelled to help track their progress within the pipeline.
|
|
80
|
+
|
|
81
|
+
* no label - these issues have not been triaged.
|
|
82
|
+
* `bug` - confirmed bug. aim to have a test case that reproduces the defect.
|
|
83
|
+
* `enhancement` - contains details/discussion of a new feature. it may not yet be approved or placed into a
|
|
84
|
+
release/milestone.
|
|
85
|
+
* `wontfix` - closed issues that were never addressed.
|
|
86
|
+
* `duplicate` - closed issue that is the same to another referenced issue.
|
|
87
|
+
* `question` - purely for discussion
|
|
88
|
+
|
|
89
|
+
### Management
|
|
90
|
+
|
|
91
|
+
When in doubt, find the maintainers and ask.
|
data/LICENSE
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) 2014 TokBox, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,81 +1,198 @@
|
|
|
1
|
-
# OpenTok
|
|
1
|
+
# OpenTok Ruby SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[tokens](http://tokbox.com/opentok/tutorials/create-token/) for [OpenTok](http://www.tokbox.com/) applications.
|
|
3
|
+
[](https://travis-ci.org/opentok/Opentok-Ruby-SDK)
|
|
5
4
|
|
|
5
|
+
The OpenTok Ruby SDK lets you generate
|
|
6
|
+
[sessions](http://www.tokbox.com/opentok/tutorials/create-session/) and
|
|
7
|
+
[tokens](http://www.tokbox.com/opentok/tutorials/create-token/) for
|
|
8
|
+
[OpenTok](http://www.tokbox.com/) applications, and
|
|
9
|
+
[archive](http://www.tokbox.com/platform/archiving) OpenTok 2.0 sessions.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
If you are updating from a previous version of this SDK, see
|
|
12
|
+
[Important changes in v2.2](#important-changes-in-v22).
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
<pre>
|
|
11
|
-
gem 'opentok'
|
|
12
|
-
</pre>
|
|
14
|
+
# Installation
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
## Bundler (recommended):
|
|
15
17
|
|
|
18
|
+
Bundler helps manage dependencies for Ruby projects. Find more info here: <http://bundler.io>
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
Add this gem to your `Gemfile`:
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
```ruby
|
|
23
|
+
gem "opentok", "~> 2.2.x"
|
|
24
|
+
```
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
Allow bundler to install the change.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
$ bundle install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## RubyGems:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
$ gem install opentok -v 2.2.0
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Usage
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
## Initializing
|
|
24
41
|
|
|
25
|
-
|
|
26
|
-
|
|
42
|
+
Load the gem at the top of any file where it will be used. Then initialize an `OpenTok::OpenTok`
|
|
43
|
+
object with your OpenTok API key and API secret.
|
|
27
44
|
|
|
28
|
-
|
|
29
|
-
|
|
45
|
+
```ruby
|
|
46
|
+
require "opentok"
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
API_KEY = '' # replace with your OpenTok API key
|
|
34
|
-
API_SECRET = '' # replace with your OpenTok API secret
|
|
35
|
-
OTSDK = OpenTok::OpenTokSDK.new API_KEY, API_SECRET
|
|
36
|
-
</pre>
|
|
48
|
+
opentok = OpenTok::OpenTok.new api_key, api_secret
|
|
49
|
+
```
|
|
37
50
|
|
|
38
51
|
## Creating Sessions
|
|
39
|
-
Call the `createSession()` method of the `OpenTokSDK` object to create a session. The method returns a Session object.
|
|
40
|
-
The `sessionId` property of the Session object is the OpenTok session ID:
|
|
41
|
-
<pre>
|
|
42
|
-
# creating an OpenTok server-enabled session
|
|
43
|
-
sessionId = OTSDK.createSession().to_s
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
To create an OpenTok Session, use the `OpenTok.create_session(properties)` method. The
|
|
54
|
+
`properties` parameter is an optional Hash used to specify whether you are creating a p2p Session
|
|
55
|
+
and specifying a location hint. The `session_id` method of the returned `OpenTok::Session`
|
|
56
|
+
instance is useful to get a sessionId that can be saved to a persistent store (e.g. database).
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
# Just a plain Session:
|
|
60
|
+
session = opentok.create_session
|
|
61
|
+
|
|
62
|
+
# The session will attempt to transmit streams directly between clients.
|
|
63
|
+
# If clients cannot connect, the session uses the OpenTok TURN server:
|
|
64
|
+
session = opentok.create_session :media_mode => :relayed
|
|
65
|
+
|
|
66
|
+
# A Session with a location hint:
|
|
67
|
+
session = opentok.create_session :location => '12.34.56.78'
|
|
68
|
+
|
|
69
|
+
# Store this sessionId in the database for later use:
|
|
70
|
+
session_id = session.session_id
|
|
71
|
+
```
|
|
49
72
|
|
|
50
73
|
## Generating Tokens
|
|
51
|
-
With the generated session ID, you can generate tokens for each user:
|
|
52
74
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
Once a Session is created, you can start generating Tokens for clients to use when connecting to it.
|
|
76
|
+
You can generate a token either by calling the `opentok.generate_token(session_id, options)` method,
|
|
77
|
+
or by calling the `session.generate_token(options)` method on the an instance after creating it. The
|
|
78
|
+
`options` parameter is an optional Hash used to set the role, expire time, and connection data of
|
|
79
|
+
the Token.
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
# Generate a Token from just a session_id (fetched from a database)
|
|
83
|
+
token = opentok.generate_token session_id
|
|
84
|
+
|
|
85
|
+
# Generate a Token by calling the method on the Session (returned from createSession)
|
|
86
|
+
token = session.generate_token
|
|
87
|
+
|
|
88
|
+
# Set some options in a token
|
|
89
|
+
token = session.generate_token({
|
|
90
|
+
:role => :moderator
|
|
91
|
+
:expire_time => Time.now.to_i+(7 * 24 * 60 * 60) # in one week
|
|
92
|
+
:data => 'name=Johnny'
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Working with Archives
|
|
97
|
+
|
|
98
|
+
You can start the recording of an OpenTok Session using the `opentok.archives.create(session_id,
|
|
99
|
+
options)` method. This will return an `OpenTok::Archive` instance. The parameter `options` is an
|
|
100
|
+
optional Hash used to assign a name for the Archive. Note that you can only start an
|
|
101
|
+
Archive on a Session that has clients connected.
|
|
102
|
+
|
|
103
|
+
```ruby
|
|
104
|
+
archive = opentok.archives.create session_id :name => "Important Presentation"
|
|
105
|
+
|
|
106
|
+
# Store this archive_id in the database for later use
|
|
107
|
+
archive_id = archive.id
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
You can stop the recording of a started Archive using the `opentok.archives.stop_by_id(archive_id)`
|
|
111
|
+
method. You can also do this using the `archive.stop` method of the `OpenTok::Archive` instance.
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
# Stop an Archive from an archive_id (fetched from database)
|
|
115
|
+
opentok.archives.stop_by_id archive_id
|
|
116
|
+
# Stop an Archive from an instance (returned from opentok.archives.create)
|
|
117
|
+
archive.stop
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
To get an `OpenTok::Archive` instance (and all the information about it) from an `archive_id`, use
|
|
121
|
+
the `opentok.archives.find(archive_id)` method.
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
archive = opentok.archives.find archive_id
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
To delete an Archive, you can call the `opentok.archives.delete_by_id(archive_id)` method or the
|
|
128
|
+
`delete` method of an `OpenTok::Archive` instance.
|
|
129
|
+
|
|
130
|
+
```ruby
|
|
131
|
+
# Delete an Archive from an archive_id (fetched from database)
|
|
132
|
+
opentok.archives.delete_by_id archive_id
|
|
133
|
+
# Delete an Archive from an Archive instance (returned from archives.create, archives.find)
|
|
134
|
+
archive.delete
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
You can also get a list of all the Archives you've created (up to 1000) with your API Key. This is
|
|
138
|
+
done using the `opentok.archives.all(options)` method. The parameter `options` is an optional Hash
|
|
139
|
+
used to specify an `:offset` and `:count` to help you paginate through the results. This will return
|
|
140
|
+
an instance of the `OpenTok::ArchiveList` class.
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
archive_list = opentok.archives.all
|
|
144
|
+
|
|
145
|
+
# Get an specific Archive from the list
|
|
146
|
+
archive_list[i]
|
|
147
|
+
# Get the total number of Archives for this API Key
|
|
148
|
+
$total = archive_list.total
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
# Samples
|
|
152
|
+
|
|
153
|
+
There are two sample applications included in this repository. To get going as fast as possible, clone the whole
|
|
154
|
+
repository and follow the Walkthroughs:
|
|
155
|
+
|
|
156
|
+
* [HelloWorld](sample/HelloWorld/README.md)
|
|
157
|
+
* [Archiving](sample/Archiving/README.md)
|
|
158
|
+
|
|
159
|
+
# Documentation
|
|
160
|
+
|
|
161
|
+
Reference documentation is available at <http://www.tokbox.com//opentok/libraries/server/ruby/reference/index.html> and in the
|
|
162
|
+
doc directory of the SDK.
|
|
163
|
+
|
|
164
|
+
# Requirements
|
|
165
|
+
|
|
166
|
+
You need an OpenTok API key and API secret, which you can obtain at <https://dashboard.tokbox.com>.
|
|
167
|
+
|
|
168
|
+
The OpenTok Ruby SDK requires Ruby 1.9.3 or greater.
|
|
169
|
+
|
|
170
|
+
# Release Notes
|
|
171
|
+
|
|
172
|
+
See the [Releases](https://github.com/opentok/opentok-ruby-sdk/releases) page for details
|
|
173
|
+
about each release.
|
|
174
|
+
|
|
175
|
+
## Important changes in v2.2
|
|
62
176
|
|
|
63
|
-
|
|
177
|
+
This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
|
|
178
|
+
work with OpenTok 1.0 archives.)
|
|
64
179
|
|
|
65
|
-
|
|
66
|
-
|
|
180
|
+
Note also that the `options` parameter of the `OpenTok.create_session()` method has a `media_mode`
|
|
181
|
+
property instead of a `p2p` property.
|
|
67
182
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
183
|
+
See the reference documentation
|
|
184
|
+
<http://www.tokbox.com/opentok/libraries/server/ruby/reference/index.html> and in the
|
|
185
|
+
docs directory of the SDK.
|
|
71
186
|
|
|
72
|
-
To install necessary gems, type `bundle install` in the root directory.
|
|
73
187
|
|
|
74
|
-
|
|
188
|
+
# Development and Contributing
|
|
75
189
|
|
|
190
|
+
Interested in contributing? We :heart: pull requests! See the [Development](DEVELOPING.md) and
|
|
191
|
+
[Contribution](CONTRIBUTING.md) guidelines.
|
|
76
192
|
|
|
77
|
-
#
|
|
193
|
+
# Support
|
|
78
194
|
|
|
79
|
-
See
|
|
195
|
+
See <http://tokbox.com/opentok/support/> for all our support options.
|
|
80
196
|
|
|
81
|
-
|
|
197
|
+
Find a bug? File it on the [Issues](https://github.com/opentok/opentok-ruby-sdk/issues) page. Hint:
|
|
198
|
+
test cases are really helpful!
|