Class: Lightstreamer::ControlConnection

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

Overview

Helper 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.



11
12
13
14
# File 'lib/lightstreamer/control_connection.rb', line 11

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 a LightstreamerError subclass will be raised.

Parameters:

  • operation (String)

    The operation to execute.

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

    The options to include on the request.

Raises:



21
22
23
24
25
26
# File 'lib/lightstreamer/control_connection.rb', line 21

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

  raise Errors::SyncError if result.first == 'SYNC ERROR'
  raise LightstreamerError.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 a LightstreamerError 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.



34
35
36
37
38
39
40
# File 'lib/lightstreamer/control_connection.rb', line 34

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

  validate_subscription_options operation, options

  execute operation, options
end