Class: OpenTok::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/opentok/connection.rb

Overview

Represents a connection in an OpenTok session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/opentok/connection.rb', line 37

def method_missing(method, *args, &block)
  camelized_method = method.to_s.camelize(:lower)
  if @json.has_key? camelized_method and args.empty?
    @json[camelized_method]
  else
    super method, *args, &block
  end
end

Instance Attribute Details

#connection_idString

The ID of the connection.

Returns:

  • (String)

    the current value of connection_id



15
16
17
# File 'lib/opentok/connection.rb', line 15

def connection_id
  @connection_id
end

#connection_stateString

The state of the connection.

Returns:

  • (String)

    the current value of connection_state



15
16
17
# File 'lib/opentok/connection.rb', line 15

def connection_state
  @connection_state
end

#created_atInteger

The timestamp when the connection was created, expressed in milliseconds since the Unix epoch.

Returns:

  • (Integer)

    the current value of created_at



15
16
17
# File 'lib/opentok/connection.rb', line 15

def created_at
  @created_at
end

Instance Method Details

#force_disconnectObject

Forces the disconnection of this connection from the OpenTok session.

A client must be actively connected to the OpenTok session for you to disconnect it.



32
33
34
# File 'lib/opentok/connection.rb', line 32

def force_disconnect
  @interface.forceDisconnect(@session_id, @json['connectionId'])
end

#to_jsonObject

A JSON-encoded string representation of the connection.



25
26
27
# File 'lib/opentok/connection.rb', line 25

def to_json
  @json.to_json
end