-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from opentok/dev
Version 4.6.0
- Loading branch information
Showing
9 changed files
with
153 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module OpenTok | ||
# @private | ||
VERSION = '4.5.1' | ||
VERSION = '4.6.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require "opentok/client" | ||
|
||
# An object that lets you work with Audio Connector WebSocket connections. | ||
module OpenTok | ||
class WebSocket | ||
# Starts an Audio Connector WebSocket connection to send audio from a Vonage Video API session to a WebSocket URI. | ||
# See the {https://tokbox.com/developer/guides/audio-connector/ OpenTok Audio Connector developer guide}. | ||
# | ||
# @example | ||
# opts = { | ||
# "streams" => ["STREAMID1", "STREAMID2"], | ||
# "headers" => { | ||
# "key1" => "val1", | ||
# "key2" => "val2" | ||
# } | ||
# } | ||
# response = opentok.websocket.connect(SESSIONID, TOKEN, "ws://service.com/wsendpoint", opts) | ||
# | ||
# @param [String] session_id (required) The OpenTok session ID that includes the OpenTok streams you want to include in | ||
# the WebSocket stream. | ||
# @param [String] token (required) The OpenTok token to be used for the Audio Connector connection to the. OpenTok session. | ||
# @param [String] websocket_uri (required) A publicly reachable WebSocket URI to be used for the destination of the audio | ||
# stream (such as "wss://service.com/ws-endpoint"). | ||
# @param [Hash] opts (optional) A hash defining options for the Audio Connector WebSocket connection. For example: | ||
# @option opts [Array] :streams (optional) An array of stream IDs for the OpenTok streams you want to include in the WebSocket stream. | ||
# If you omit this property, all streams in the session will be included. | ||
# @option opts [Hash] :headers (optional) A hash of key-value pairs of headers to be sent to your WebSocket server with each message, | ||
# with a maximum length of 512 bytes. | ||
def connect(session_id, token, websocket_uri, opts = {}) | ||
response = @client.connect_websocket(session_id, token, websocket_uri, opts) | ||
end | ||
|
||
def initialize(client) | ||
@client = client | ||
end | ||
end | ||
end |
37 changes: 37 additions & 0 deletions
37
spec/cassettes/OpenTok_WebSocket/receives_a_valid_response.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "opentok/opentok" | ||
require "opentok/websocket" | ||
require "opentok/version" | ||
require "spec_helper" | ||
|
||
describe OpenTok::WebSocket do | ||
before(:each) do | ||
now = Time.parse("2017-04-18 20:17:40 +1000") | ||
allow(Time).to receive(:now) { now } | ||
end | ||
|
||
let(:api_key) { "123456" } | ||
let(:api_secret) { "1234567890abcdef1234567890abcdef1234567890" } | ||
let(:session_id) { "SESSIONID" } | ||
let(:connection_id) { "CONNID" } | ||
let(:expiring_token) { "TOKENID" } | ||
let(:websocket_uri) { "ws://service.com/wsendpoint" } | ||
let(:opentok) { OpenTok::OpenTok.new api_key, api_secret } | ||
let(:websocket) { opentok.websocket } | ||
subject { websocket } | ||
|
||
it "receives a valid response", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do | ||
response = websocket.connect(session_id, expiring_token, websocket_uri) | ||
expect(response).not_to be_nil | ||
end | ||
end |