Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bug Fix for opentok Gem #3

Merged
merged 3 commits into from

2 participants

@songz

There is a bug in the gemfile, it can be replicated like this:

opentok = OpenTok::OpenTokSDK.new(API_KEY, API_SECRET)
session = opentok.create_session( 'https://api.opentok.com/hl', {'p2p.preference' => 'enabled'})

The resulting session created is not p2p enabled in the production environment.

I went through the code and this issue is caused by the @api_url not being set by the location parameter passed into the create_session function.

Thanks Stijnster! Any comment is appreciated, this is my first pull request!

Song Zheng added some commits
Song Zheng content type 94be448
Song Zheng Revert "content type"
This reverts commit 94be448.
2abd312
Song Zheng Bug fix: p2p sessions previously cannot be created because api_url wa…
…s not set in create_session function
a905aeb
@stijnster stijnster referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@stijnster stijnster merged commit 4025e0f into stijnster:master
@stijnster
Owner

Hi Song,

I've merged it in and I'll create a new version and push that to rubygems.

Thanks!

Stijn

@stijnster
Owner

Hi Song,

me again. Your modifications seem to brake the unit tests. The location parameter that you specify is not meant to provide the api_url. The api_url should be set with the creation of a new OpentTokSDK object like this;

opentok = OpenTok::OpenTokSDK.new @api_key, @api_secret, :api_url => 'https://api.opentok.com/hl'

The location parameter that is specified in the create_session method is used to indicate where the requesting server is located (documentation in the sdk file describes it as; Generates a new OpenTok::Session and set it's session_id, situating it in TokBox's global network near the IP of the specified @location@.)

Can you retest, setting the api_url in the correct way and see if it works?

Just a tip; if you install "rspec" on your system, you can run the testsuite. Go to the folder where the source code is located and from there type "rspec" on the prompt.

Please let me know if I can be of any help!

Kind regards,

Stijn

@songz

You are absolutely right. I had a wrong understanding and was chasing a non-existent bug. Sorry.

@stijnster
Owner

No problem!

Talk to you soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2012
  1. content type

    Song Zheng authored
Commits on Apr 23, 2012
  1. Revert "content type"

    Song Zheng authored
    This reverts commit 94be448.
  2. Bug fix: p2p sessions previously cannot be created because api_url wa…

    Song Zheng authored
    …s not set in create_session function
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  lib/open_tok/open_tok_sdk.rb
View
3  lib/open_tok/open_tok_sdk.rb
@@ -122,6 +122,9 @@ def generate_token(opts = {})
# See http://www.tokbox.com/opentok/tools/documentation/overview/session_creation.html for more information
def create_session(location='', opts={})
opts.merge!({:partner_id => @partner_id, :location=>location})
+ if location!=''
+ @api_url = location
+ end
doc = do_request("/session/create", opts)
if not doc.get_elements('Errors').empty?
raise OpenTokException.new doc.get_elements('Errors')[0].get_elements('error')[0].children.to_s
Something went wrong with that request. Please try again.