Class: Lightstreamer::ControlConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/lightstreamer/control_connection.rb

Overview

This is an internal class used by Session and is responsible for sending Lightstreamer control requests.

Instance Method Summary collapse

Constructor Details

#initialize(session_id, control_url) ⇒ ControlConnection

Initializes this class for sending Lightstreamer control requests using the specified session ID and control address.

Parameters:

  • session_id (String)

    The Lightstreamer session ID.

  • control_url (String)

    The URL of the server to send Lightstreamer control requests to.



9
10
11
12
# File 'lib/lightstreamer/control_connection.rb', line 9

def initialize(session_id, control_url)
  @session_id = session_id
  @control_url = URI.join(control_url, '/lightstreamer/control.txt').to_s
end

Instance Method Details

#execute(options) ⇒ Object

Sends a Lightstreamer control request with the specified options. If an error occurs then RequestError or ProtocolError will be raised.

Parameters:

  • options (Hash)

    The control request options.

Options Hash (options):

  • :table (Fixnum)

    The ID of the table this request pertains to. Required.

  • :operation (:add, :add_silent, :start, :delete)

    The operation to perform. Required.

  • :adapter (String)

    The name of the data adapter to use. Optional.

  • :items (Array<String>)

    The names of the items that this request pertains to. Required if :operation is :add or :add_silent.

  • :fields (Array<String>)

    The names of the fields that this request pertains to. Required if :operation is :add or :add_silent.

  • :mode (:raw, :merge, :distinct, :command)

    The subscription mode.

Raises:



26
27
28
29
30
# File 'lib/lightstreamer/control_connection.rb', line 26

def execute(options)
  result = execute_post_request build_payload(options)

  raise ProtocolError.new(result[2], result[1]) if result.first == 'ERROR'
end