opentok 4.5.1 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78dc7ec3b0d8d3097e687cc0e7b76d2c9d18e3969372c54a00e3c4f3c95846ed
4
- data.tar.gz: e8c10144c89329205734d7d0dd5c8fb37197c2af0a50401a1d97ec1cbfe9e837
3
+ metadata.gz: '019bb7945d8571c4805cab88854fd49914fac7fbb7169b2b1351fa393237ea46'
4
+ data.tar.gz: 9f167173216875bbc1b52bd2239c7fff7e9ff49c4aa92c28e6541d9fb178782d
5
5
  SHA512:
6
- metadata.gz: 9b481dc1985ffa39e3c371c2d67fc3b6e7b1cdc696db7e21274bea45e0784984facb5cdfdda92bc14f3366af243e8c01f448bc5ddb7cba52e935a8c97bd15694
7
- data.tar.gz: f776558162063de46f8e7e4da99032ec771171098f7cc2e4a2c260374061ec0c840d479e530b2efb24f8ad3754f0da95a27c12a24cdd97c0013680ac31e5b5f7
6
+ metadata.gz: e24be36a973fd9fe2ed63a620dbff3f0cb2fa24939318fd0f353a76374c8c09e4e46c8c920e223015c6b536dfbeddc2d94e75909f6cc3fbb54e6b39f85077402
7
+ data.tar.gz: 29b06c9529e61f19208d0c875ddf0caba12652afaaa4f87f59760a3c664a69b6a1686f200f1793a730b8518ec1d2f99cbd0ea7a29ee7ab2c5bcc7d42cb2b2af6
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 4.7.0
2
+
3
+ * Adds support for the End-to-end encryption (E2EE) feature [#259](https://github.com/opentok/OpenTok-Ruby-SDK/pull/259)
4
+ * Implements Auto-archive improvements [#262](https://github.com/opentok/OpenTok-Ruby-SDK/pull/262)
5
+ * Updates the README to explain appending a custom value to the `UserAgent` header [#263](https://github.com/opentok/OpenTok-Ruby-SDK/pull/263)
6
+
7
+ # 4.6.0
8
+
9
+ * Adds functionality for working with the Audio Connector feature [#247](https://github.com/opentok/OpenTok-Ruby-SDK/pull/247)
10
+
1
11
  # 4.5.1
2
12
 
3
13
  * Fixes issue with uninitialized constant by adding missing `require` statement [#256](https://github.com/opentok/OpenTok-Ruby-SDK/pull/256)
data/README.md CHANGED
@@ -18,6 +18,7 @@ The OpenTok Ruby SDK provides methods for:
18
18
  * [Disconnecting clients from sessions](https://tokbox.com/developer/guides/moderation/rest/)
19
19
  * [Forcing clients in a session to disconnect or mute published audio](https://tokbox.com/developer/guides/moderation/)
20
20
  * Working with OpenTok [Experience Composers](https://tokbox.com/developer/guides/experience-composer)
21
+ * Working with OpenTok [Audio Connector](https://tokbox.com/developer/guides/audio-connector)
21
22
 
22
23
  ## Installation
23
24
 
@@ -58,6 +59,8 @@ opentok = OpenTok::OpenTok.new api_key, api_secret
58
59
 
59
60
  #### Initialization Options
60
61
 
62
+ **Custom Timeout**
63
+
61
64
  You can specify a custom timeout value for HTTP requests when initializing a new `OpenTok::OpenTok`
62
65
  object:
63
66
 
@@ -70,6 +73,23 @@ opentok = OpenTok::OpenTok.new api_key, api_secret, :timeout_length => 10
70
73
  The value for `:timeout_length` is an integer representing the number of seconds to wait for an HTTP
71
74
  request to complete. The default is set to 2 seconds.
72
75
 
76
+ **UA Addendum**
77
+
78
+ You can also append a custom string to the `User-Agent` header value for HTTP requests when initializing a new `OpenTok::OpenTok`
79
+ object:
80
+
81
+ ```ruby
82
+ require "opentok"
83
+
84
+ opentok = OpenTok::OpenTok.new api_key, api_secret, :ua_addendum => 'FOO'
85
+ ```
86
+
87
+ The above would generate a `User-Agent` header something like this:
88
+
89
+ ```
90
+ User-Agent: OpenTok-Ruby-SDK/4.6.0-Ruby-Version-3.1.2-p20 FOO
91
+ ```
92
+
73
93
  ### Creating Sessions
74
94
 
75
95
  To create an OpenTok Session, use the `OpenTok#create_session(properties)` method.
@@ -100,6 +120,9 @@ session = opentok.create_session :location => '12.34.56.78'
100
120
  # A session with automatic archiving (must use the routed media mode):
101
121
  session = opentok.create_session :archive_mode => :always, :media_mode => :routed
102
122
 
123
+ # A session with end-to-end encryption (must use the routed media mode):
124
+ session = opentok.create_session :e2ee => true, :media_mode => :routed
125
+
103
126
  # Store this sessionId in the database for later use:
104
127
  session_id = session.session_id
105
128
  ```
@@ -188,7 +211,10 @@ archive = opentok.archives.create session_id :output_mode => :individual
188
211
  The `:output_mode => :composed` setting (the default) causes all streams in the archive to be
189
212
  recorded to a single (composed) file.
190
213
 
191
- For composed archives you can set the resolution of the archive, either "640x480" (SD landscape, the default), "1280x720" (HD landscape), "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait).. The `resolution` parameter is optional and could be included in the options
214
+ For composed archives you can set the resolution of the archive, either "640x480"
215
+ (SD landscape, the default), "1280x720" (HD landscape), "1920x1080" (FHD landscape),
216
+ "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait).
217
+ The `resolution` parameter is optional and could be included in the options
192
218
  hash (second argument) of the `opentok.archives.create()` method.
193
219
 
194
220
  ```ruby
@@ -322,7 +348,7 @@ For more information on archiving, see the
322
348
 
323
349
  ### Signaling
324
350
 
325
- You can send a signal using the `opentok.signals.send(session_id, connection_id, opts)` method.
351
+ You can send a signal using the `opentok.signals.send(session_id, connection_id, opts)` method.
326
352
  If `connection_id` is nil or an empty string, then the signal is send to all valid connections in
327
353
  the session.
328
354
 
@@ -457,7 +483,7 @@ You can cause a client to be forced to disconnect from a session by using the
457
483
 
458
484
  ### Forcing clients in a session to mute published audio
459
485
 
460
- You can force the publisher of a specific stream to stop publishing audio using the
486
+ You can force the publisher of a specific stream to stop publishing audio using the
461
487
  `opentok.streams.force_mute(session_id, stream_id)` method.
462
488
 
463
489
  You can force the publisher of all streams in a session (except for an optional list of streams)
@@ -495,6 +521,11 @@ You can stop an Experience Composer by calling the `opentok.renders.stop(render_
495
521
  You can get information about Experience Composers by calling the `opentok.renders.find(render_id)`
496
522
  and `opentok.renders.list(options)` methods.
497
523
 
524
+ ### Working with Audio Connector
525
+
526
+ You can start an [Audio Connector](https://tokbox.com/developer/guides/audio-connector) WebSocket
527
+ by calling the `opentok.websocket.connect()` method.
528
+
498
529
  ## Samples
499
530
 
500
531
  There are three sample applications included in this repository. To get going as fast as possible, clone the whole
@@ -298,6 +298,35 @@ module OpenTok
298
298
  raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
299
299
  end
300
300
 
301
+ def connect_websocket(session_id, token, websocket_uri, opts)
302
+ opts.extend(HashExtensions)
303
+ body = { "sessionId" => session_id,
304
+ "token" => token,
305
+ "websocket" => { "uri" => websocket_uri }.merge(opts.camelize_keys!)
306
+ }
307
+
308
+ response = self.class.post("/v2/project/#{@api_key}/connect", {
309
+ :body => body.to_json,
310
+ :headers => generate_headers("Content-Type" => "application/json")
311
+ })
312
+ case response.code
313
+ when 200
314
+ response
315
+ when 400
316
+ raise ArgumentError, "One of the properties is invalid."
317
+ when 403
318
+ raise OpenTokAuthenticationError, "You are not authorized to start the call, check your authentication information."
319
+ when 409
320
+ raise OpenTokWebSocketError, "Conflict. Only routed sessions are allowed to initiate Connect Calls."
321
+ when 500
322
+ raise OpenTokError, "OpenTok server error."
323
+ else
324
+ raise OpenTokWebSocketError, "The WebSocket could not be connected"
325
+ end
326
+ rescue StandardError => e
327
+ raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
328
+ end
329
+
301
330
  def dial(session_id, token, sip_uri, opts)
302
331
  opts.extend(HashExtensions)
303
332
  body = { "sessionId" => session_id,
@@ -14,7 +14,8 @@ module OpenTok
14
14
  class OpenTokStreamLayoutError < OpenTokError; end
15
15
  # Defines errors raised when you perform Broadcast operations.
16
16
  class OpenTokBroadcastError < OpenTokError; end
17
+ # Defines errors raised when connecting to WebSocket URIs.
18
+ class OpenTokWebSocketError < OpenTokError; end
17
19
  # Defines errors raised when you perform Experience Composer render operations.
18
20
  class OpenTokRenderError < OpenTokError; end
19
-
20
21
  end
@@ -144,11 +144,26 @@ module OpenTok
144
144
  # automatically (<code>:always</code>) or not (<code>:manual</code>). When using automatic
145
145
  # archiving, the session must use the <code>:routed</code> media mode.
146
146
  #
147
+ # @option opts [Symbol] :archive_name The name to use for archives in auto-archived sessions.
148
+ # When setting this option, the :archive_mode option must be set to :always or an error will result.
149
+ # The length of the archive name can be up to 80 chars.
150
+ # Due to encoding limitations the following special characters are translated to a colon (:) character: ~, -, _.
151
+ # If you do not set a name and the archiveMode option is set to always, the archive name will be empty.
152
+ #
153
+ # @option opts [Symbol] :archive_resolution The resolution of archives in an auto-archived session.
154
+ # Valid values are "480x640", "640x480" (the default), "720x1280", "1280x720", "1080x1920", and "1920x1080".
155
+ # When setting this option, the :archive_mode option must be set to :always or an error will result.
156
+ #
157
+ # @option opts [true, false] :e2ee
158
+ # (Boolean, optional) — Whether the session uses end-to-end encryption from client to client (default: false).
159
+ # This should not be set to `true` if `:media_mode` is `:relayed`.
160
+ # See the {https://tokbox.com/developer/guides/end-to-end-encryption/ documentation} for more information.
161
+ #
147
162
  # @return [Session] The Session object. The session_id property of the object is the session ID.
148
163
  def create_session(opts={})
149
164
 
150
165
  # normalize opts so all keys are symbols and only include valid_opts
151
- valid_opts = [ :media_mode, :location, :archive_mode ]
166
+ valid_opts = [ :media_mode, :location, :archive_mode, :archive_name, :archive_resolution, :e2ee ]
152
167
  opts = opts.inject({}) do |m,(k,v)|
153
168
  if valid_opts.include? k.to_sym
154
169
  m[k.to_sym] = v
@@ -159,6 +174,13 @@ module OpenTok
159
174
  # keep opts around for Session constructor, build REST params
160
175
  params = opts.clone
161
176
 
177
+ # validate input combinations
178
+ raise ArgumentError, "A session with always archive mode must also have the routed media mode." if (params[:archive_mode] == :always && params[:media_mode] == :relayed)
179
+
180
+ raise ArgumentError, "A session with relayed media mode should not have e2ee set to true." if (params[:media_mode] == :relayed && params[:e2ee] == true)
181
+
182
+ raise ArgumentError, "A session with always archive mode must not have e2ee set to true." if (params[:archive_mode] == :always && params[:e2ee] == true)
183
+
162
184
  # anything other than :relayed sets the REST param to "disabled", in which case we force
163
185
  # opts to be :routed. if we were more strict we could raise an error when the value isn't
164
186
  # either :relayed or :routed
@@ -175,10 +197,9 @@ module OpenTok
175
197
  # archive mode is optional, but it has to be one of the valid values if present
176
198
  unless params[:archive_mode].nil?
177
199
  raise "archive mode must be either always or manual" unless ARCHIVE_MODES.include? params[:archive_mode].to_sym
200
+ raise ArgumentError, "archive name and/or archive resolution must not be set if archive mode is manual" if params[:archive_mode] == :manual && (params[:archive_name] || params[:archive_resolution])
178
201
  end
179
202
 
180
- raise "A session with always archive mode must also have the routed media mode." if (params[:archive_mode] == :always && params[:media_mode] == :relayed)
181
-
182
203
  response = client.create_session(params)
183
204
  Session.new api_key, api_secret, response['sessions']['Session']['session_id'], opts
184
205
  end
@@ -218,6 +239,11 @@ module OpenTok
218
239
  @connections ||= Connections.new client
219
240
  end
220
241
 
242
+ # A WebSocket object, which lets you connect OpenTok streams to a WebSocket URI.
243
+ def websocket
244
+ @websocket ||= WebSocket.new client
245
+ end
246
+
221
247
  protected
222
248
  def client
223
249
  @client ||= Client.new api_key, api_secret, api_url, ua_addendum, timeout_length: @timeout_length
@@ -20,6 +20,10 @@ module OpenTok
20
20
  # @attr_reader [String] archive_mode Whether the session will be archived automatically
21
21
  # (<code>:always</code>) or not (<code>:manual</code>).
22
22
  #
23
+ # @attr_reader [String] archive_name The name to use for archives in auto-archived sessions.
24
+ #
25
+ # @attr_reader [String] :archive_resolution The resolution of archives in an auto-archived session.
26
+ #
23
27
  # @!method generate_token(options)
24
28
  # Generates a token.
25
29
  #
@@ -57,7 +61,7 @@ module OpenTok
57
61
  :session_id => ->(instance) { instance.session_id }
58
62
  })
59
63
 
60
- attr_reader :session_id, :media_mode, :location, :archive_mode, :api_key, :api_secret
64
+ attr_reader :session_id, :media_mode, :location, :archive_mode, :archive_name, :archive_resolution, :e2ee, :api_key, :api_secret
61
65
 
62
66
  # @private
63
67
  # this implementation doesn't completely understand the format of a Session ID
@@ -73,7 +77,12 @@ module OpenTok
73
77
  # @private
74
78
  def initialize(api_key, api_secret, session_id, opts={})
75
79
  @api_key, @api_secret, @session_id = api_key, api_secret, session_id
76
- @media_mode, @location, @archive_mode = opts.fetch(:media_mode, :relayed), opts[:location], opts.fetch(:archive_mode, :manual)
80
+ @media_mode = opts.fetch(:media_mode, :relayed)
81
+ @location = opts[:location]
82
+ @archive_mode = opts.fetch(:archive_mode, :manual)
83
+ @archive_name = opts.fetch(:archive_name, '') if archive_mode == :always
84
+ @archive_resolution = opts.fetch(:archive_resolution, "640x480") if archive_mode == :always
85
+ @e2ee = opts.fetch(:e2ee, :false)
77
86
  end
78
87
 
79
88
  # @private
@@ -1,4 +1,4 @@
1
1
  module OpenTok
2
2
  # @private
3
- VERSION = '4.5.1'
3
+ VERSION = '4.7.0'
4
4
  end
@@ -0,0 +1,37 @@
1
+ require "opentok/client"
2
+
3
+ # An object that lets you work with Audio Connector WebSocket connections.
4
+ module OpenTok
5
+ class WebSocket
6
+ # Starts an Audio Connector WebSocket connection to send audio from a Vonage Video API session to a WebSocket URI.
7
+ # See the {https://tokbox.com/developer/guides/audio-connector/ OpenTok Audio Connector developer guide}.
8
+ #
9
+ # @example
10
+ # opts = {
11
+ # "streams" => ["STREAMID1", "STREAMID2"],
12
+ # "headers" => {
13
+ # "key1" => "val1",
14
+ # "key2" => "val2"
15
+ # }
16
+ # }
17
+ # response = opentok.websocket.connect(SESSIONID, TOKEN, "ws://service.com/wsendpoint", opts)
18
+ #
19
+ # @param [String] session_id (required) The OpenTok session ID that includes the OpenTok streams you want to include in
20
+ # the WebSocket stream.
21
+ # @param [String] token (required) The OpenTok token to be used for the Audio Connector connection to the. OpenTok session.
22
+ # @param [String] websocket_uri (required) A publicly reachable WebSocket URI to be used for the destination of the audio
23
+ # stream (such as "wss://service.com/ws-endpoint").
24
+ # @param [Hash] opts (optional) A hash defining options for the Audio Connector WebSocket connection. For example:
25
+ # @option opts [Array] :streams (optional) An array of stream IDs for the OpenTok streams you want to include in the WebSocket stream.
26
+ # If you omit this property, all streams in the session will be included.
27
+ # @option opts [Hash] :headers (optional) A hash of key-value pairs of headers to be sent to your WebSocket server with each message,
28
+ # with a maximum length of 512 bytes.
29
+ def connect(session_id, token, websocket_uri, opts = {})
30
+ response = @client.connect_websocket(session_id, token, websocket_uri, opts)
31
+ end
32
+
33
+ def initialize(client)
34
+ @client = client
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/session/create
6
+ body:
7
+ encoding: UTF-8
8
+ string: archiveMode=always&archiveName=foo&p2p.preference=disabled
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Mon, 12 Jun 2023 16:17:36 GMT
27
+ Content-Type:
28
+ - text/xml
29
+ Connection:
30
+ - keep-alive
31
+ Access-Control-Allow-Origin:
32
+ - '*'
33
+ X-Tb-Host:
34
+ - fms503-nyc.tokbox.com
35
+ Content-Length:
36
+ - '282'
37
+ body:
38
+ encoding: UTF-8
39
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><sessions><Session><session_id>1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg</session_id><partner_id>123456</partner_id><create_dt>Mon
40
+ Jun 12 16:17:36 GMT 2023</create_dt></Session></sessions>
41
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
42
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/session/create
6
+ body:
7
+ encoding: UTF-8
8
+ string: archiveMode=always&archiveName=foo&archiveResolution=720x1280&p2p.preference=disabled
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Mon, 12 Jun 2023 16:17:36 GMT
27
+ Content-Type:
28
+ - text/xml
29
+ Connection:
30
+ - keep-alive
31
+ Access-Control-Allow-Origin:
32
+ - '*'
33
+ X-Tb-Host:
34
+ - fms503-nyc.tokbox.com
35
+ Content-Length:
36
+ - '282'
37
+ body:
38
+ encoding: UTF-8
39
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><sessions><Session><session_id>1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg</session_id><partner_id>123456</partner_id><create_dt>Mon
40
+ Jun 12 16:17:36 GMT 2023</create_dt></Session></sessions>
41
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
42
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/session/create
6
+ body:
7
+ encoding: UTF-8
8
+ string: archiveMode=always&archiveResolution=720x1280&p2p.preference=disabled
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Mon, 12 Jun 2023 16:17:36 GMT
27
+ Content-Type:
28
+ - text/xml
29
+ Connection:
30
+ - keep-alive
31
+ Access-Control-Allow-Origin:
32
+ - '*'
33
+ X-Tb-Host:
34
+ - fms503-nyc.tokbox.com
35
+ Content-Length:
36
+ - '282'
37
+ body:
38
+ encoding: UTF-8
39
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><sessions><Session><session_id>1_MX4xMjM0NTZ-fk1vbiBNYXIgMTcgMDA6NDE6MzEgUERUIDIwMTR-MC42ODM3ODk1MzQ0OTQyODA4fg</session_id><partner_id>123456</partner_id><create_dt>Mon
40
+ Jun 12 16:17:36 GMT 2023</create_dt></Session></sessions>
41
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
42
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/session/create
6
+ body:
7
+ encoding: UTF-8
8
+ string: e2ee=true&p2p.preference=disabled
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Tue, 18 Apr 2023 16:17:40 GMT
25
+ Content-Type:
26
+ - text/xml
27
+ Connection:
28
+ - keep-alive
29
+ Access-Control-Allow-Origin:
30
+ - '*'
31
+ X-Tb-Host:
32
+ - mantis503-nyc.tokbox.com
33
+ Content-Length:
34
+ - '304'
35
+ body:
36
+ encoding: UTF-8
37
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><sessions><Session><session_id>1_MX4xMjM0NTZ-MTIuMzQuNTYuNzh-TW9uIE1hciAxNyAwMTo0ODo1NSBQRFQgMjAxNH4wLjM0MTM0MzE0MDIyOTU4Mjh-</session_id><partner_id>123456</partner_id><create_dt>Tue
38
+ Apr 18 08:17:40 PDT 2023</create_dt></Session></sessions>
39
+ recorded_at: Tue, 18 Apr 2023 16:17:40 GMT
40
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,37 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/v2/project/123456/connect
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"sessionId":"SESSIONID","token":"TOKENID","websocket":{"uri":"ws://service.com/wsendpoint"}}'
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Sat, 06 Aug 2022 18:10:28 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Content-Length:
30
+ - '73'
31
+ Connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"id":"2299ba24-a6de-417c-88f7-28da54a441cf","connectionId":"833a7182-61a5-49d4-baae-c324b09953af"}'
36
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
37
+ recorded_with: VCR 6.0.0
@@ -97,6 +97,7 @@ describe OpenTok::OpenTok do
97
97
  expect(session.media_mode).to eq :relayed
98
98
  expect(session.location).to eq nil
99
99
  end
100
+
100
101
  it "creates always archived sessions", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
101
102
  session = opentok.create_session :media_mode => :routed, :archive_mode => :always
102
103
  expect(session).to be_an_instance_of OpenTok::Session
@@ -105,9 +106,80 @@ describe OpenTok::OpenTok do
105
106
  expect(session.location).to eq nil
106
107
  end
107
108
 
109
+ it "creates always archived sessions with a set archive name", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
110
+ session = opentok.create_session :media_mode => :routed, :archive_mode => :always, :archive_name => 'foo'
111
+ expect(session).to be_an_instance_of OpenTok::Session
112
+ expect(session.session_id).to be_an_instance_of String
113
+ expect(session.archive_mode).to eq :always
114
+ expect(session.archive_name).to eq 'foo'
115
+ expect(session.location).to eq nil
116
+ end
117
+
118
+ it "creates always archived sessions with a set archive resolution", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
119
+ session = opentok.create_session :media_mode => :routed, :archive_mode => :always, :archive_resolution => "720x1280"
120
+ expect(session).to be_an_instance_of OpenTok::Session
121
+ expect(session.session_id).to be_an_instance_of String
122
+ expect(session.archive_mode).to eq :always
123
+ expect(session.archive_resolution).to eq "720x1280"
124
+ expect(session.location).to eq nil
125
+ end
126
+
127
+ it "creates always archived sessions with a set archive name and resolution", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
128
+ session = opentok.create_session :media_mode => :routed, :archive_mode => :always, :archive_name => 'foo', :archive_resolution => "720x1280"
129
+ expect(session).to be_an_instance_of OpenTok::Session
130
+ expect(session.session_id).to be_an_instance_of String
131
+ expect(session.archive_mode).to eq :always
132
+ expect(session.archive_name).to eq 'foo'
133
+ expect(session.archive_resolution).to eq "720x1280"
134
+ expect(session.location).to eq nil
135
+ end
136
+
137
+ it "creates e2ee sessions", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
138
+ session = opentok.create_session :media_mode => :routed, :e2ee => :true
139
+ expect(session).to be_an_instance_of OpenTok::Session
140
+ expect(session.session_id).to be_an_instance_of String
141
+ expect(session.e2ee).to eq :true
142
+ expect(session.location).to eq nil
143
+ end
144
+
108
145
  context "with relayed media mode and always archive mode" do
109
- subject { -> { session = opentok.create_session :archive_mode => :always, :media_mode => :relayed }}
110
- it { should raise_error }
146
+ it "raises an error" do
147
+ expect {
148
+ opentok.create_session :archive_mode => :always, :media_mode => :relayed
149
+ }.to raise_error ArgumentError
150
+ end
151
+ end
152
+
153
+ context "with archive name set and manual archive mode" do
154
+ it "raises an error" do
155
+ expect {
156
+ opentok.create_session :archive_mode => :manual, :archive_name => 'foo'
157
+ }.to raise_error ArgumentError
158
+ end
159
+ end
160
+
161
+ context "with archive resolution set and manual archive mode" do
162
+ it "raises an error" do
163
+ expect {
164
+ opentok.create_session :archive_mode => :manual, :archive_resolution => "720x1280"
165
+ }.to raise_error ArgumentError
166
+ end
167
+ end
168
+
169
+ context "with relayed media mode and e2ee set to true" do
170
+ it "raises an error" do
171
+ expect {
172
+ opentok.create_session :media_mode => :relayed, :e2ee => true
173
+ }.to raise_error ArgumentError
174
+ end
175
+ end
176
+
177
+ context "with always archive mode and e2ee set to true" do
178
+ it "raises an error" do
179
+ expect {
180
+ opentok.create_session :archive_mode => :always, :e2ee => true
181
+ }.to raise_error ArgumentError
182
+ end
111
183
  end
112
184
 
113
185
  end
@@ -0,0 +1,26 @@
1
+ require "opentok/opentok"
2
+ require "opentok/websocket"
3
+ require "opentok/version"
4
+ require "spec_helper"
5
+
6
+ describe OpenTok::WebSocket do
7
+ before(:each) do
8
+ now = Time.parse("2017-04-18 20:17:40 +1000")
9
+ allow(Time).to receive(:now) { now }
10
+ end
11
+
12
+ let(:api_key) { "123456" }
13
+ let(:api_secret) { "1234567890abcdef1234567890abcdef1234567890" }
14
+ let(:session_id) { "SESSIONID" }
15
+ let(:connection_id) { "CONNID" }
16
+ let(:expiring_token) { "TOKENID" }
17
+ let(:websocket_uri) { "ws://service.com/wsendpoint" }
18
+ let(:opentok) { OpenTok::OpenTok.new api_key, api_secret }
19
+ let(:websocket) { opentok.websocket }
20
+ subject { websocket }
21
+
22
+ it "receives a valid response", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
23
+ response = websocket.connect(session_id, expiring_token, websocket_uri)
24
+ expect(response).not_to be_nil
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentok
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.1
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stijn Mathysen
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-10-28 00:00:00.000000000 Z
15
+ date: 2023-06-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -206,6 +206,7 @@ files:
206
206
  - lib/opentok/streams.rb
207
207
  - lib/opentok/token_generator.rb
208
208
  - lib/opentok/version.rb
209
+ - lib/opentok/websocket.rb
209
210
  - opentok.gemspec
210
211
  - sample/Archiving/Gemfile
211
212
  - sample/Archiving/README.md
@@ -281,7 +282,11 @@ files:
281
282
  - spec/cassettes/OpenTok_Broadcasts/stops_a_broadcast.yml
282
283
  - spec/cassettes/OpenTok_Connections/forces_a_connection_to_be_terminated.yml
283
284
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions.yml
285
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions_with_a_set_archive_name.yml
286
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions_with_a_set_archive_name_and_resolution.yml
287
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions_with_a_set_archive_resolution.yml
284
288
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_default_sessions.yml
289
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_e2ee_sessions.yml
285
290
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions.yml
286
291
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_for_invalid_media_modes.yml
287
292
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_with_a_location_hint.yml
@@ -308,6 +313,7 @@ files:
308
313
  - spec/cassettes/OpenTok_Streams/get_all_streams_information.yml
309
314
  - spec/cassettes/OpenTok_Streams/get_specific_stream_information.yml
310
315
  - spec/cassettes/OpenTok_Streams/layout_working_on_two_stream_list.yml
316
+ - spec/cassettes/OpenTok_WebSocket/receives_a_valid_response.yml
311
317
  - spec/matchers/token.rb
312
318
  - spec/opentok/archives_spec.rb
313
319
  - spec/opentok/broadcasts_spec.rb
@@ -319,6 +325,7 @@ files:
319
325
  - spec/opentok/signal_spec.rb
320
326
  - spec/opentok/sip_spec.rb
321
327
  - spec/opentok/streams_spec.rb
328
+ - spec/opentok/websocket_spec.rb
322
329
  - spec/shared/opentok_generates_tokens.rb
323
330
  - spec/shared/session_generates_tokens.rb
324
331
  - spec/spec_helper.rb
@@ -391,7 +398,11 @@ test_files:
391
398
  - spec/cassettes/OpenTok_Broadcasts/stops_a_broadcast.yml
392
399
  - spec/cassettes/OpenTok_Connections/forces_a_connection_to_be_terminated.yml
393
400
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions.yml
401
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions_with_a_set_archive_name.yml
402
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions_with_a_set_archive_name_and_resolution.yml
403
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions_with_a_set_archive_resolution.yml
394
404
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_default_sessions.yml
405
+ - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_e2ee_sessions.yml
395
406
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions.yml
396
407
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_for_invalid_media_modes.yml
397
408
  - spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_with_a_location_hint.yml
@@ -418,6 +429,7 @@ test_files:
418
429
  - spec/cassettes/OpenTok_Streams/get_all_streams_information.yml
419
430
  - spec/cassettes/OpenTok_Streams/get_specific_stream_information.yml
420
431
  - spec/cassettes/OpenTok_Streams/layout_working_on_two_stream_list.yml
432
+ - spec/cassettes/OpenTok_WebSocket/receives_a_valid_response.yml
421
433
  - spec/matchers/token.rb
422
434
  - spec/opentok/archives_spec.rb
423
435
  - spec/opentok/broadcasts_spec.rb
@@ -429,6 +441,7 @@ test_files:
429
441
  - spec/opentok/signal_spec.rb
430
442
  - spec/opentok/sip_spec.rb
431
443
  - spec/opentok/streams_spec.rb
444
+ - spec/opentok/websocket_spec.rb
432
445
  - spec/shared/opentok_generates_tokens.rb
433
446
  - spec/shared/session_generates_tokens.rb
434
447
  - spec/spec_helper.rb