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(operation, options = {}) ⇒ Object

Sends a Lightstreamer control request that executes the specified operation with the specified options. If an error occurs then an Error subclass will be raised.

Parameters:

  • operation (String)

    The operation to execute.

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

    The options to include on the request.



19
20
21
22
23
# File 'lib/lightstreamer/control_connection.rb', line 19

def execute(operation, options = {})
  result = execute_post_request build_payload(operation, options)

  raise Error.build(result[2], result[1]) if result.first != 'OK'
end

#subscription_execute(operation, table, options = {}) ⇒ Object

Sends a Lightstreamer subscription control request with the specified operation, table, and options. If an error occurs then an Error subclass will be raised.

Parameters:

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

    The operation to execute.

  • table (Fixnum)

    The ID of the table this request pertains to.

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

    The subscription control request options.

Options Hash (options):

  • :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 (:distinct, :merge)

    The subscription mode. Required if operation is :add or :add_silent.

  • :selector (String)

    The selector for table items. Optional.



39
40
41
42
43
44
45
# File 'lib/lightstreamer/control_connection.rb', line 39

def subscription_execute(operation, table, options = {})
  options[:table] = table

  validate_subscription_options operation, options

  execute operation, options
end