opentok 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +34 -113
- data/doc/reference.md +122 -0
- data/lib/open_tok/exception.rb +3 -6
- data/lib/open_tok/request.rb +2 -2
- data/lib/open_tok/version.rb +1 -1
- data/sample/sample.rb +26 -0
- data/spec/cassettes/session.yml +1 -1
- data/spec/cassettes/stitchArchive.yml +1 -1
- data/spec/opentok_spec.rb +4 -4
- metadata +19 -77
- data/doc/CHANGES.html +0 -128
- data/doc/Gemfile.html +0 -114
- data/doc/Hash.html +0 -228
- data/doc/LICENCE.html +0 -133
- data/doc/Net.html +0 -167
- data/doc/Net/HTTP.html +0 -260
- data/doc/OpenTok.html +0 -173
- data/doc/OpenTok/OpenTokException.html +0 -172
- data/doc/OpenTok/OpenTokSDK.html +0 -520
- data/doc/OpenTok/RoleConstants.html +0 -190
- data/doc/OpenTok/Session.html +0 -284
- data/doc/OpenTok/SessionPropertyConstants.html +0 -195
- data/doc/Rakefile.html +0 -111
- data/doc/created.rid +0 -13
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -100
- data/doc/js/darkfish.js +0 -116
- data/doc/js/jquery.js +0 -32
- data/doc/js/quicksearch.js +0 -114
- data/doc/js/thickbox-compressed.js +0 -10
- data/doc/lib/monkey_patches_rb.html +0 -52
- data/doc/lib/open_tok/exceptions_rb.html +0 -52
- data/doc/lib/open_tok/open_tok_sdk_rb.html +0 -64
- data/doc/lib/open_tok/session_rb.html +0 -52
- data/doc/lib/open_tok/version_rb.html +0 -52
- data/doc/lib/opentok_rb.html +0 -70
- data/doc/rdoc.css +0 -706
- data/doc/spec/opentok_spec_rb.html +0 -54
- data/doc/spec/spec_helper_rb.html +0 -54
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0122202a607892b2550a526dc44c35b2beea87c8
|
4
|
+
data.tar.gz: b005eb0fba4ee0bdcec3123c87042936ff70673e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a15810ae54376c9442277c4cfd33ca3532378b5b0093a961cc6781734adf747f90771286fece4e428ecbcf143453152211f775ae1b99ef147031a7a4f5bec75
|
7
|
+
data.tar.gz: e85e3a3832c6984c7ec975e6acba8ff45669e8287f009fea12d7ec1ff77f6f0bc77c99f8bb12cbf4edd0438ebb985ebbb17629003028a02e44de1f39008150bf
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# OpenTok Server SDK for Ruby
|
2
|
+
|
3
|
+
The OpenTok server SDK for Ruby lets you generate [sessions](http://tokbox.com/opentok/tutorials/create-session/) and
|
4
|
+
[tokens](http://tokbox.com/opentok/tutorials/create-token/) for [OpenTok](http://www.tokbox.com/) applications.
|
2
5
|
|
3
|
-
OpenTok is an API from TokBox that enables websites to weave live group video communication into their online experience. Check out <http://www.tokbox.com/> for more information.
|
4
|
-
This is the official OpenTok Ruby Server SDK for generating Sessions, Tokens, and retriving Archives. Please visit our [getting started page](http://www.tokbox.com/opentok/tools/js/gettingstarted) if you are unfamiliar with these concepts.
|
5
6
|
|
6
7
|
## Installation
|
7
8
|
|
@@ -12,136 +13,57 @@ gem 'opentok'
|
|
12
13
|
|
13
14
|
To install as a regular gem just type `gem install opentok`
|
14
15
|
|
16
|
+
|
15
17
|
## Requirements
|
16
18
|
|
17
|
-
|
19
|
+
The OpenTok server SDK for Ruby requires Ruby 1.9 or greater.
|
20
|
+
|
21
|
+
You need an OpenTok API key and API secret, which you can obtain at <https://dashboard.tokbox.com>.
|
18
22
|
|
19
23
|
# OpenTokSDK
|
20
24
|
|
21
25
|
In order to use any of the server side functions, you must first create an `OpenTokSDK` object with your developer credentials.
|
22
|
-
`OpenTokSDK` takes
|
23
|
-
|
24
|
-
|
26
|
+
`OpenTokSDK` takes two parameters:
|
27
|
+
|
28
|
+
* key (string) - Given to you when you register
|
29
|
+
* secret (string) - Given to you when you register
|
25
30
|
|
26
31
|
<pre>
|
27
32
|
# Creating an OpenTok Object
|
28
|
-
API_KEY = ''
|
29
|
-
API_SECRET = ''
|
33
|
+
API_KEY = '' # replace with your OpenTok API key
|
34
|
+
API_SECRET = '' # replace with your OpenTok API secret
|
30
35
|
OTSDK = OpenTok::OpenTokSDK.new API_KEY, API_SECRET
|
31
36
|
</pre>
|
32
37
|
|
33
|
-
|
34
38
|
## Creating Sessions
|
35
|
-
|
36
|
-
`
|
37
|
-
> location (string) - OPTIONAL. a location so OpenTok can stream through the closest server
|
38
|
-
> properties (object) - OPTIONAL. Set peer to peer as `enabled` or `disabled`. Disabled by default
|
39
|
-
|
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:
|
40
41
|
<pre>
|
41
|
-
# creating
|
42
|
+
# creating an OpenTok server-enabled session
|
42
43
|
sessionId = OTSDK.createSession().to_s
|
43
44
|
|
44
|
-
# Creating
|
45
|
-
|
46
|
-
|
47
|
-
# Creating Session object with p2p enabled
|
48
|
-
sessionProperties = {OpenTok::SessionPropertyConstants::P2P_PREFERENCE => "enabled"} # or disabled
|
49
|
-
sessionId = OTSDK.createSession( @location, sessionProperties ).to_s
|
45
|
+
# Creating peer-to-peer session
|
46
|
+
sessionProperties = {OpenTok::SessionPropertyConstants::P2P_PREFERENCE => "enabled"}
|
47
|
+
sessionId = OTSDK.createSession( nil, sessionProperties ).to_s
|
50
48
|
</pre>
|
51
49
|
|
52
50
|
## Generating Tokens
|
53
|
-
With the generated
|
54
|
-
`generate_token` takes in hash with 1-4 properties:
|
55
|
-
> session_id (string) - REQUIRED
|
56
|
-
> role (string) - OPTIONAL. subscriber, publisher, or moderator
|
57
|
-
> expire_time (int) - OPTIONAL. Time when token will expire in unix timestamp
|
58
|
-
> connection_data (string) - OPTIONAL. Metadata to store data (names, user id, etc)
|
51
|
+
With the generated session ID, you can generate tokens for each user:
|
59
52
|
|
60
53
|
<pre>
|
61
|
-
# Generating a token
|
62
|
-
token = OTSDK.generateToken :session_id =>
|
54
|
+
# Generating a publisher token
|
55
|
+
token = OTSDK.generateToken :session_id => sessionId
|
56
|
+
|
57
|
+
# Generating a token with moderator role and connection data
|
58
|
+
role = OpenTok::RoleConstants::MODERATOR
|
59
|
+
connection_data = "username=Bob,level=4"
|
60
|
+
token = OTSDK.generateToken :session_id => sessionId, :role => role, :connection_data => connection_data
|
63
61
|
</pre>
|
64
62
|
|
65
63
|
Possible Errors:
|
66
|
-
> "Null or empty session ID are not valid"
|
67
|
-
> "An invalid session ID was passed"
|
68
|
-
|
69
|
-
## Manipulating Archive Videos
|
70
|
-
To Download or delete archived video, you must have an Archive ID which you get from the javascript library. If you are unfamiliar with archiving concepts, please visit our [archiving tutorial](http://www.tokbox.com/opentok/api/documentation/gettingstartedarchiving)
|
71
|
-
|
72
|
-
## Delete Archives
|
73
|
-
OpenTok SDK has a function `deleteArchive` that lets you delete videos in a recorded archive.
|
74
|
-
Use your `OpenTokSDK` object to call `deleteArchive`
|
75
|
-
`deleteArchive` takes in 2 parameters and returns a true or false boolean representing the success of the delete request
|
76
|
-
> archive_id (string) - REQUIRED
|
77
|
-
> token (string) - REQUIRED. This token MUST have a moderator role, and it should be generated with the same session_id used to create the archive
|
78
|
-
> **returns**
|
79
|
-
true: Success, the archive is deleted
|
80
|
-
false: Archive does not exist (perhaps it was already deleted or never created), invalid token (perhaps it does not have the moderator role or it's generated with the wrong session_id)
|
81
|
-
|
82
|
-
Example:
|
83
|
-
<pre>
|
84
|
-
successful = OTSDK.deleteArchive( archive_id, token )
|
85
|
-
</pre>
|
86
|
-
|
87
|
-
# Stitching Archives
|
88
|
-
OpenTok SDK allows you to stich up to 4 videos together in an archive.
|
89
|
-
Use your `OpenTokSDK` object to call stitchArchive
|
90
|
-
stitchArchive takes in 1 parameter and returns a hash object with code, message, and location if stitch is successful.
|
91
|
-
> archive_id (string) - REQUIRED
|
92
|
-
> **returns**:
|
93
|
-
{:code=>201, :message=>"Successfully Created", :location=>response["location"]}
|
94
|
-
{:code=>202, :message=>"Processing"}
|
95
|
-
{:code=>403, :message=>"Invalid Credentials"}
|
96
|
-
{:code=>404, :message=>"Archive Does Not Exist"}
|
97
|
-
{:code=>500, :message=>"Server Error"}
|
98
|
-
|
99
|
-
Example:
|
100
|
-
<pre>
|
101
|
-
result = OTSDK.stitchArchive archive_id
|
102
|
-
if result[:code] == 201
|
103
|
-
return result[:location]
|
104
|
-
end
|
105
|
-
</pre>
|
106
64
|
|
107
|
-
|
108
|
-
|
109
|
-
`getArchiveManifest()` takes in 2 parameters: **archiveId** and **moderator token**
|
110
|
-
> archive_id (string) - REQUIRED.
|
111
|
-
> token (string) - REQUIRED.
|
112
|
-
> **returns** an `OpenTokArchive` object.
|
113
|
-
The *resources* property of this object is array of `OpenTokArchiveVideoResource` objects, and each `OpenTokArchiveVideoResource` object represents a video in the archive.
|
114
|
-
|
115
|
-
Example:(Make sure you have the OpentokSDK Object)
|
116
|
-
<pre>
|
117
|
-
@token = '...' # token generated with corresponding session
|
118
|
-
@archiveId = '5f74aee5-ab3f-421b-b124-ed2a698ee939' #Obtained from Javascript Library
|
119
|
-
otArchive = OTSDK.getArchiveManifest(@archiveId, @token)
|
120
|
-
</pre>
|
121
|
-
|
122
|
-
# Get video ID
|
123
|
-
`OpenTokArchive.resources` is an array of `OpenTokArchiveVideoResource` objects. OpenTokArchiveVideoResource has `getId()` method that returns the video_id
|
124
|
-
`getId()` will return the video ID (a String)
|
125
|
-
|
126
|
-
Example:
|
127
|
-
<pre>
|
128
|
-
otArchive = OTSDK.getArchiveManifest(@archiveId, @token)
|
129
|
-
otVideoResource = otArchive.resources[0]
|
130
|
-
videoId = otVideoResource.getId()
|
131
|
-
</pre>
|
132
|
-
|
133
|
-
# Get Download Url
|
134
|
-
`OpenTokArchive` has `downloadArchiveURL` that will return an url string for downloading the video in the archive. You must call this function every time you want the file, because this url expires after 24 hours
|
135
|
-
> video_id (string) - REQUIRED
|
136
|
-
> token (string) - REQUIRED
|
137
|
-
> returns url string
|
138
|
-
|
139
|
-
Example:
|
140
|
-
<pre>
|
141
|
-
url = otArchive.downloadArchiveURL(video_id, token)
|
142
|
-
</pre>
|
143
|
-
|
144
|
-
-----
|
65
|
+
* "Null or empty session ID are not valid"
|
66
|
+
* "An invalid session ID was passed"
|
145
67
|
|
146
68
|
# Contributing
|
147
69
|
To contribute, simple fork this repository and send a pull request when you are done.
|
@@ -151,10 +73,9 @@ To install necessary gems, type `bundle install` in the root directory.
|
|
151
73
|
|
152
74
|
To run test cases, type `rspec spec/` in the root directory.
|
153
75
|
|
154
|
-
-----
|
155
76
|
|
156
|
-
|
77
|
+
# More information
|
78
|
+
|
79
|
+
See the [reference documentation](doc/reference.md).
|
157
80
|
|
158
|
-
|
159
|
-
Build gem: `gem build opentok.gemspec`
|
160
|
-
Push gem: `gem push opentok-*.gem`
|
81
|
+
For more information on OpenTok, go to <http://www.tokbox.com/>.
|
data/doc/reference.md
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
OpenTok Ruby SDK reference
|
2
|
+
==========================
|
3
|
+
|
4
|
+
You need to instantiate an OpenTokSDK object before calling any of its methods.
|
5
|
+
To create a new OpenTokSDK object, call the OpenTokSDK constructor with the API key
|
6
|
+
and the API secret TokBox issued you. (You get an API key when you
|
7
|
+
<a href="https://dashboard.tokbox.com/users/sign_in">sign up</a> for an OpenTok account.) Do not reveal
|
8
|
+
your API secret string. You use it with the OpenTokSDK constructor (only on your web
|
9
|
+
server) to create OpenTok sessions.
|
10
|
+
|
11
|
+
API_KEY = '' # should be a string
|
12
|
+
API_SECRET = '' # should be a string
|
13
|
+
OTSDK = OpenTok::OpenTokSDK.new API_KEY, API_SECRET
|
14
|
+
|
15
|
+
create_session() method
|
16
|
+
-----------------------
|
17
|
+
The `create_session()` method of the OpenTokSDK object to create a new OpenTok
|
18
|
+
session and obtain a session ID.
|
19
|
+
|
20
|
+
The `create_session()` method has the following parameters:
|
21
|
+
|
22
|
+
* `location` (String) — An IP address that TokBox will use to situate the session in its global network.
|
23
|
+
In general, you should not pass in a location hint (or pass in nil); if no location hint is passed in, the session
|
24
|
+
uses a media server based on the location of the first client connecting to the session. Pass a location hint in only
|
25
|
+
if you know the general geographic region (and a representative IP address) and you think the first client connecting
|
26
|
+
may not be in that region.
|
27
|
+
|
28
|
+
* `properties` (Object) — Optional. An object used to define
|
29
|
+
peer-to-peer preferences for the session. The `properties` option includes one property —
|
30
|
+
`p2p.preference` (a string). This property determines whether the session's streams will
|
31
|
+
be transmitted directly between peers. You can set the following possible values:
|
32
|
+
|
33
|
+
* "disabled" (the default) — The session's streams will all be relayed using the OpenTok media server.
|
34
|
+
<br><br>
|
35
|
+
**In OpenTok v2:** The <a href="http://www.tokbox.com/blog/mantis-next-generation-cloud-technology-for-webrtc/">OpenTok
|
36
|
+
media server</a> provides benefits not available in peer-to-peer sessions. For example, the OpenTok media server can
|
37
|
+
decrease bandwidth usage in multiparty sessions. Also, the OpenTok server can improve the quality of the user experience
|
38
|
+
through <a href="http://www.tokbox.com/blog/quality-of-experience-and-traffic-shaping-the-next-step-with-mantis/">dynamic
|
39
|
+
traffic shaping</a>. For information on pricing, see the <a href="http://www.tokbox.com/pricing">OpenTok pricing page</a>.
|
40
|
+
|
41
|
+
* "enabled" — The session will attempt to transmit streams directly between clients.
|
42
|
+
<br><br>
|
43
|
+
**In OpenTok v1:** Peer-to-peer streaming decreases latency and improves quality. If peer-to-peer streaming
|
44
|
+
fails (either when streams are initially published or during the course of a session), the session falls back to using
|
45
|
+
the OpenTok media server to relaying streams. (Peer-to-peer streaming uses UDP, which may be blocked by a firewall.)
|
46
|
+
For a session created with peer-to-peer streaming enabled, only two clients can connect to the session at a time.
|
47
|
+
If an additional client attempts to connect, the TB object on the client dispatches an exception event.
|
48
|
+
|
49
|
+
|
50
|
+
The `create_session` method returns a Session object. This
|
51
|
+
object includes a `sessionID` property, which is the session ID for the
|
52
|
+
new session. For example, when using the OpenTok JavaScript library, use this
|
53
|
+
session ID in JavaScript on the page that you serve to the client.
|
54
|
+
The JavaScript will use this value when calling the `connect()`
|
55
|
+
method of the Session object (to connect a user to an OpenTok session).
|
56
|
+
|
57
|
+
OpenTok sessions do not expire. However, authentication tokens do expire (see the next section on the
|
58
|
+
generate_token() method.) Also note that sessions cannot explicitly be destroyed.
|
59
|
+
|
60
|
+
Calling the `create_session()` method results in an `OpenTokException`
|
61
|
+
in the event of an error. Check the error message for details.
|
62
|
+
|
63
|
+
Here is a simple that creates a OpenTok server-enabled session:
|
64
|
+
|
65
|
+
sessionId = OTSDK.createSession().to_s
|
66
|
+
|
67
|
+
Here is an example that creates a peer-to-peer session:
|
68
|
+
|
69
|
+
sessionProperties = {OpenTok::SessionPropertyConstants::P2P_PREFERENCE => "enabled"}
|
70
|
+
sessionId = OTSDK.createSession( nil, sessionProperties ).to_s
|
71
|
+
|
72
|
+
You can also create a session using the <a href="http://www.tokbox.com/opentok/api/#session_id_production">OpenTok
|
73
|
+
REST API</a> or the <a href="https://dashboard.tokbox.com/projects">OpenTok dashboard</a>.
|
74
|
+
|
75
|
+
|
76
|
+
generate_token() method
|
77
|
+
-----------------------
|
78
|
+
|
79
|
+
In order to authenticate a user connecting to a OpenTok
|
80
|
+
session, a user must pass an authentication token along with the API key.
|
81
|
+
|
82
|
+
The method has the following parameters:
|
83
|
+
|
84
|
+
* `session_id` (String) — The session ID corresponding to the session to which the user will connect.
|
85
|
+
|
86
|
+
* `role` (String) — Optional. Each role defines a set of permissions granted to the token.
|
87
|
+
Valid values are defined in the RoleConstants class in the server-side SDKs:
|
88
|
+
|
89
|
+
* `SUBSCRIBER` — A subscriber can only subscribe to streams.</li>
|
90
|
+
|
91
|
+
* `PUBLISHER` — A publisher can publish streams, subscribe to streams, and signal.
|
92
|
+
(This is the default value if you do not specify a value for the `role` parameter.)</li>
|
93
|
+
|
94
|
+
* `MODERATOR` — In addition to the privileges granted to a publisher, a moderator
|
95
|
+
can call the `forceUnpublish()` and `forceDisconnect()` method of the
|
96
|
+
Session object.</li>
|
97
|
+
|
98
|
+
* `expire_time` (int) — Optional. The time when the token
|
99
|
+
will expire, defined as an integer value for a Unix timestamp (in seconds).
|
100
|
+
If you do not specify this value, tokens expire in 24 hours after being created.
|
101
|
+
The `expiration_time` value, if specified, must be within 30 days
|
102
|
+
of the creation time.
|
103
|
+
|
104
|
+
* `connection_data` (String) — Optional. A string containing metadata describing the connection.
|
105
|
+
For example, you can pass the user ID, name, or other data describing the connection.
|
106
|
+
The length of the string is limited to 1000 characters.
|
107
|
+
|
108
|
+
Calling the `generate_token()` method returns the token string.
|
109
|
+
|
110
|
+
The following code example shows how to obtain a publisher token:
|
111
|
+
|
112
|
+
token = OTSDK.generateToken :session_id => sessionId
|
113
|
+
|
114
|
+
The following PHP code example shows how to obtain a token that has a role of "moderator" and that has
|
115
|
+
a connection metadata string:
|
116
|
+
|
117
|
+
role = OpenTok::RoleConstants::MODERATOR
|
118
|
+
connection_data = "username=Bob,level=4"
|
119
|
+
token = OTSDK.generateToken :session_id => sessionId, :role => role, :connection_data => connection_data
|
120
|
+
|
121
|
+
For testing, you can also use the <a href="https://dashboard.tokbox.com/projects">OpenTok dashboard</a>
|
122
|
+
page to generate test tokens.
|
data/lib/open_tok/exception.rb
CHANGED
@@ -11,8 +11,7 @@ module OpenTok
|
|
11
11
|
# The exception that gets thrown when an invalid api-key and/or secret is given.
|
12
12
|
class OpenTokException < RuntimeError
|
13
13
|
|
14
|
-
def initialize(
|
15
|
-
@code = code
|
14
|
+
def initialize(message)
|
16
15
|
@mesasge = message
|
17
16
|
end
|
18
17
|
|
@@ -29,11 +28,9 @@ module OpenTok
|
|
29
28
|
# Generates the relevant exception instance based on the XML error data received
|
30
29
|
def from_error(error)
|
31
30
|
child = error.get_elements('Errors')[0].get_elements('error')[0]
|
32
|
-
code = child.attributes['code']
|
33
|
-
exception = exceptions.find{|exc| exc.http_code == code }
|
34
31
|
exception ||= self
|
35
32
|
message = child.children.empty? ? '' : child.children[0].attributes['message']
|
36
|
-
exception.new
|
33
|
+
exception.new message
|
37
34
|
end
|
38
35
|
|
39
36
|
# To be overriden by subclasses
|
@@ -50,4 +47,4 @@ module OpenTok
|
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
|
-
end
|
50
|
+
end
|
data/lib/open_tok/request.rb
CHANGED
@@ -44,9 +44,9 @@ module OpenTok
|
|
44
44
|
end
|
45
45
|
|
46
46
|
rescue Net::HTTPExceptions => e
|
47
|
-
raise OpenTokException.new
|
47
|
+
raise OpenTokException.new "Unable to create fufill request: #{e}"
|
48
48
|
rescue NoMethodError => e
|
49
|
-
raise OpenTokException.new
|
49
|
+
raise OpenTokException.new "Unable to create a fufill request at this time: #{e}"
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
data/lib/open_tok/version.rb
CHANGED
data/sample/sample.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'opentok'
|
2
|
+
|
3
|
+
API_KEY = '' # See https://dashboard.tokbox.com/
|
4
|
+
API_SECRET = '' # See https://dashboard.tokbox.com/
|
5
|
+
|
6
|
+
OTSDK = OpenTok::OpenTokSDK.new API_KEY, API_SECRET
|
7
|
+
|
8
|
+
# Create an OpenTok server-enabled session
|
9
|
+
sessionId = OTSDK.createSession().to_s
|
10
|
+
print sessionId + "\n"
|
11
|
+
|
12
|
+
# Create a peer-to-peer session
|
13
|
+
sessionProperties = {OpenTok::SessionPropertyConstants::P2P_PREFERENCE => "enabled"} # or disabled
|
14
|
+
sessionId = OTSDK.createSession( nil, sessionProperties ).to_s
|
15
|
+
print sessionId + "\n"
|
16
|
+
|
17
|
+
# Generate a publisher token
|
18
|
+
token = OTSDK.generateToken :session_id => sessionId
|
19
|
+
print token + "\n"
|
20
|
+
|
21
|
+
# Generate a token with moderator role and connection data
|
22
|
+
role = OpenTok::RoleConstants::MODERATOR
|
23
|
+
connection_data = "username=Bob,level=4, score=8888888888"
|
24
|
+
token = OTSDK.generateToken :session_id => sessionId, :role => role, :connection_data => connection_data
|
25
|
+
print token + "\n"
|
26
|
+
|
data/spec/cassettes/session.yml
CHANGED
data/spec/opentok_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe OpenTok do
|
4
4
|
|
5
5
|
let(:api_key) { '459782' }
|
6
|
-
let(:api_secret) { '
|
6
|
+
let(:api_secret) { '***REMOVED***' }
|
7
7
|
let(:api_url) { 'http://api.opentok.com/hl' }
|
8
8
|
let(:host) { 'localhost' }
|
9
9
|
|
@@ -78,7 +78,7 @@ describe OpenTok do
|
|
78
78
|
describe "Archiving downloads" do
|
79
79
|
use_vcr_cassette "archives"
|
80
80
|
let(:api_key) { '459782' }
|
81
|
-
let(:api_secret) { '
|
81
|
+
let(:api_secret) { '***REMOVED***' }
|
82
82
|
let(:opentok) { OpenTok::OpenTokSDK.new api_key, api_secret, {:api_url=>""} }
|
83
83
|
let(:opts) { {:partner_id => api_key, :location=>host} }
|
84
84
|
|
@@ -105,7 +105,7 @@ describe OpenTok do
|
|
105
105
|
describe "Delete Archives" do
|
106
106
|
use_vcr_cassette "deleteArchive"
|
107
107
|
let(:api_key) { '459782' }
|
108
|
-
let(:api_secret) { '
|
108
|
+
let(:api_secret) { '***REMOVED***' }
|
109
109
|
let(:opentok) { OpenTok::OpenTokSDK.new api_key, api_secret, {:api_url => ""} }
|
110
110
|
let(:session) { '1_MX40NTk3ODJ-MTI3LjAuMC4xflR1ZSBTZXAgMDQgMTQ6NTM6MDIgUERUIDIwMTJ-MC41MjExODEzfg' }
|
111
111
|
let(:token) { opentok.generateToken({:session_id => session, :role=>OpenTok::RoleConstants::PUBLISHER}) }
|
@@ -121,7 +121,7 @@ describe OpenTok do
|
|
121
121
|
describe "stitch api" do
|
122
122
|
use_vcr_cassette "stitchArchive"
|
123
123
|
let(:api_key) { '459782' }
|
124
|
-
let(:api_secret) { '
|
124
|
+
let(:api_secret) { '***REMOVED***' }
|
125
125
|
let(:opentok) { OpenTok::OpenTokSDK.new api_key, api_secret }
|
126
126
|
let(:archiveId) { "200567af-0726-4e93-883b-fe0426d6310a" }
|
127
127
|
|