Class: OpenTok::Signals

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

Overview

A class for working with OpenTok signals.

Instance Method Summary collapse

Instance Method Details

#send(session_id, connectionId = "", options = {}) ⇒ Object

Sends a signal to clients connected to an OpenTok session.

You can send a signal to all valid connections in a session or to a specific connection of a session.

For more information on signaling, see https://tokbox.com/developer/rest/#send_signal.

field to group and filter signals. It is a property of the Signal object received by the client(s).

Contains the main information to be sent in the signal. It is a property of the Signal object received by the client(s).

Parameters:

  • session_id (String)

    The session ID of the OpenTok session.

  • connection_id (String)

    When a connection_id is specified, only that connection recieves the signal. Otherwise, the signal is sent to all clients connected to the session.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :type (String)

    This is the type of the signal. You can use this

  • :data (String)

    This is the data within the signal or the payload.

Raises:

  • (ArgumentError)

    One of the signal properties — data, type, session_id, or connection_id — is invalid.

  • (OpenTokAuthenticationError)

    You are not authorized to send the signal. Check your authentication credentials.

  • (OpenTokError)

    The client specified by the connection_id property is not connected to the session.

  • (OpenTokError)

    The type string exceeds the maximum length (128 bytes), or the data string exceeds the maximum size (8 kB).



40
41
42
43
44
# File 'lib/opentok/signals.rb', line 40

def send(session_id, connectionId = "", options = {})
  raise ArgumentError, "session_id not provided" if session_id.to_s.empty?
  response = @client.signal(session_id, connectionId, options)
  (200..300).include? response.code
end