Sha256: 99b99329af407af9b070cdbfc09bdf397a2bdccb2e184e3040c750854d197239

Contents?: true

Size: 1.91 KB

Versions: 20

Compression:

Stored size: 1.91 KB

Contents

module OpenTok
  #  A class for working with OpenTok signals.
  class Signals
    # @private
    def initialize(client)
      @client = client
    end

    # 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}.
    #
    # @param [String] session_id The session ID of the OpenTok session.
    #
    # @param [String] connection_id
    #   When a connection_id is specified, only that connection recieves the signal. 
    #   Otherwise, the signal is sent to all clients connected to the session.
    #
    # @option options [String] :type This is the type of the signal. You can use this
    # field to group and filter signals. It is a property of the Signal object received by
    # the client(s).
    #
    # @option options [String] :data This is the data within the signal or the payload.
    # Contains the main information to be sent in the signal. It is a property of the Signal object
    # received by the client(s).
    #
    # @raise [ArgumentError]
    #   One of the signal properties — data, type, session_id, or connection_id — is invalid.
    # @raise [OpenTokAuthenticationError]
    #   You are not authorized to send the signal. Check your authentication credentials.
    # @raise [OpenTokError]
    #   The client specified by the connection_id property is not connected to the session.
    # @raise [OpenTokError]
    #   The type string exceeds the maximum length (128 bytes), or the data string exceeds
    #   the maximum size (8 kB).
    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

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
opentok-4.12.0 lib/opentok/signals.rb
opentok-4.11.0 lib/opentok/signals.rb
opentok-4.10.0 lib/opentok/signals.rb
opentok-4.9.0 lib/opentok/signals.rb
opentok-4.8.1 lib/opentok/signals.rb
opentok-4.8.0 lib/opentok/signals.rb
opentok-4.7.1 lib/opentok/signals.rb
opentok-4.7.0 lib/opentok/signals.rb
opentok-4.6.0 lib/opentok/signals.rb
opentok-4.5.1 lib/opentok/signals.rb
opentok-4.5.0 lib/opentok/signals.rb
opentok-4.4.0 lib/opentok/signals.rb
opentok-4.3.0 lib/opentok/signals.rb
opentok-4.2.0 lib/opentok/signals.rb
opentok-4.1.2 lib/opentok/signals.rb
opentok-4.1.1 lib/opentok/signals.rb
opentok-4.1.0 lib/opentok/signals.rb
opentok-4.0.1 lib/opentok/signals.rb
opentok-4.0.0 lib/opentok/signals.rb
opentok-3.1.0 lib/opentok/signals.rb