Sha256: 5281543ab6105c9376f2fbdd6f2287987a5e7fa976cb3a686e28a30aad168b45

Contents?: true

Size: 695 Bytes

Versions: 34

Compression:

Stored size: 695 Bytes

Contents

require 'sinatra/base'
require 'opentok'

raise "You must define API_KEY and API_SECRET environment variables" unless ENV.has_key?("API_KEY") && ENV.has_key?("API_SECRET")

class HelloWorld < Sinatra::Base

  set :api_key, ENV['API_KEY']
  set :opentok, OpenTok::OpenTok.new(api_key, ENV['API_SECRET'])
  set :session, opentok.create_session

  get '/' do

    api_key = settings.api_key
    session_id = settings.session.session_id
    token = settings.opentok.generate_token(session_id)

    erb :index, :locals => {
      :api_key => api_key,
      :session_id => session_id,
      :token => token
    }
  end

  # start the server if ruby file executed directly
  run! if app_file == $0
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
opentok-4.9.0 sample/HelloWorld/hello_world.rb
opentok-4.8.1 sample/HelloWorld/hello_world.rb
opentok-4.8.0 sample/HelloWorld/hello_world.rb
opentok-4.7.1 sample/HelloWorld/hello_world.rb
opentok-4.7.0 sample/HelloWorld/hello_world.rb
opentok-4.6.0 sample/HelloWorld/hello_world.rb
opentok-4.5.1 sample/HelloWorld/hello_world.rb
opentok-4.5.0 sample/HelloWorld/hello_world.rb
opentok-4.4.0 sample/HelloWorld/hello_world.rb
opentok-4.3.0 sample/HelloWorld/hello_world.rb
opentok-4.2.0 sample/HelloWorld/hello_world.rb
opentok-4.1.2 sample/HelloWorld/hello_world.rb
opentok-4.1.1 sample/HelloWorld/hello_world.rb
opentok-4.1.0 sample/HelloWorld/hello_world.rb
opentok-4.0.1 sample/HelloWorld/hello_world.rb
opentok-4.0.0 sample/HelloWorld/hello_world.rb
opentok-3.1.0 sample/HelloWorld/hello_world.rb
opentok-3.0.3 sample/HelloWorld/hello_world.rb
opentok-3.0.2 sample/HelloWorld/hello_world.rb
opentok-3.0.1 sample/HelloWorld/hello_world.rb