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.
Instance Attribute Summary collapse
-
#:archive_resolution ⇒ String
readonly
The resolution of archives in an auto-archived session.
-
#archive_mode ⇒ String
readonly
Whether the session will be archived automatically (
:always
) or not (:manual
). -
#archive_name ⇒ String
readonly
The name to use for archives in auto-archived sessions.
-
#archive_resolution ⇒ Object
readonly
Returns the value of attribute archive_resolution.
-
#e2ee ⇒ Object
readonly
Returns the value of attribute e2ee.
-
#location ⇒ String
readonly
The location hint IP address.
-
#media_mode ⇒ String
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.
-
#session_id ⇒ String
readonly
The session ID.
Instance Method Summary collapse
-
#generate_token(options) ⇒ String
Generates a token.
Instance Attribute Details
#:archive_resolution ⇒ String (readonly)
The resolution of archives in an auto-archived session.
55 56 57 |
# File 'lib/opentok/session.rb', line 55
def :archive_resolution
@:archive_resolution
end
|
#archive_mode ⇒ String (readonly)
Whether the session will be archived automatically (:always
) or not (:manual
).
55 56 57 |
# File 'lib/opentok/session.rb', line 55 def archive_mode @archive_mode end |
#archive_name ⇒ String (readonly)
The name to use for archives in auto-archived sessions.
55 56 57 |
# File 'lib/opentok/session.rb', line 55 def archive_name @archive_name end |
#archive_resolution ⇒ Object (readonly)
Returns the value of attribute archive_resolution.
64 65 66 |
# File 'lib/opentok/session.rb', line 64 def archive_resolution @archive_resolution end |
#e2ee ⇒ Object (readonly)
Returns the value of attribute e2ee.
64 65 66 |
# File 'lib/opentok/session.rb', line 64 def e2ee @e2ee end |
#location ⇒ String (readonly)
The location hint IP address. See the OpenTok.createSession() method.
55 56 57 |
# File 'lib/opentok/session.rb', line 55 def location @location end |
#media_mode ⇒ String (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.
55 56 57 |
# File 'lib/opentok/session.rb', line 55 def media_mode @media_mode end |
#session_id ⇒ String (readonly)
The session ID.
55 56 57 |
# File 'lib/opentok/session.rb', line 55 def session_id @session_id end |
Instance Method Details
#generate_token(options) ⇒ String
Generates a token.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/opentok/session.rb', line 55 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, :archive_name, :archive_resolution, :e2ee, :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 = opts.fetch(:media_mode, :relayed) @location = opts[:location] @archive_mode = opts.fetch(:archive_mode, :manual) @archive_name = opts.fetch(:archive_name, '') if archive_mode == :always @archive_resolution = opts.fetch(:archive_resolution, "640x480") if archive_mode == :always @e2ee = opts.fetch(:e2ee, :false) end # @private def to_s @session_id end end |