Class: OpenTok::Session
- Inherits:
-
Object
- Object
- OpenTok::Session
- Defined in:
- lib/opentok/session.rb
Overview
Represents an OpenTok session.
Use the OpenTok.createSession() method to create an OpenTok session. Use the session_id property of the Session object to get the session ID.
Constant Summary
Instance Attribute Summary (collapse)
-
- (String) archive_mode
readonly
Whether the session will be archived automatically (:always) or not (:manual).
-
- (String) location
readonly
The location hint IP address.
-
- (String) media_mode
readonly
Set to :routed if the session uses the OpenTok Media Router or to :relayed if the session attempts to transmit streams directly between clients.
-
- (String) session_id
readonly
The session ID.
Instance Method Summary (collapse)
-
- (String) generate_token(options)
Generates a token.
Instance Attribute Details
- (String) archive_mode (readonly)
Whether the session will be archived automatically (:always) or not (:manual).
46 47 48 |
# File 'lib/opentok/session.rb', line 46 def archive_mode @archive_mode end |
- (String) location (readonly)
The location hint IP address. See the OpenTok.createSession() method.
46 47 48 |
# File 'lib/opentok/session.rb', line 46 def location @location end |
- (String) media_mode (readonly)
Set to :routed if the session uses the OpenTok Media Router or to :relayed if the session attempts to transmit streams directly between clients.
46 47 48 |
# File 'lib/opentok/session.rb', line 46 def media_mode @media_mode end |
- (String) session_id (readonly)
The session ID.
46 47 48 |
# File 'lib/opentok/session.rb', line 46 def session_id @session_id end |
Instance Method Details
- (String) generate_token(options)
Generates a token.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/opentok/session.rb', line 46 class Session include TokenGenerator generates_tokens({ :api_key => ->(instance) { instance.api_key }, :api_secret => ->(instance) { instance.api_secret }, :session_id => ->(instance) { instance.session_id } }) attr_reader :session_id, :media_mode, :location, :archive_mode, :api_key, :api_secret # @private # this implementation doesn't completely understand the format of a Session ID # that is intentional, that is too much responsibility. def self.belongs_to_api_key?(session_id, api_key) encoded = session_id[2..session_id.length] .gsub('-', '+') .gsub('_', '/') decoded = Base64.decode64(encoded) decoded.include? api_key end # @private def initialize(api_key, api_secret, session_id, opts={}) @api_key, @api_secret, @session_id = api_key, api_secret, session_id @media_mode, @location, @archive_mode = opts.fetch(:media_mode, :relayed), opts[:location], opts.fetch(:archive_mode, :manual) end # @private def to_s @session_id end end |