Class: Lightstreamer::StreamConnectionHeader

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

Overview

Internal class used by StreamConnection that processes the contents of the header returned by the server when a new stream connection is created or an existing session is bound to.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStreamConnectionHeader

Returns a new instance of StreamConnectionHeader.



13
14
15
16
# File 'lib/lightstreamer/stream_connection_header.rb', line 13

def initialize
  @data = {}
  @lines = []
end

Instance Attribute Details

#errorLightstreamerError? (readonly)

If there was an error in the header then this attribute will be set to the error instance that should be raised in response.

Returns:



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

def error
  @error
end

Instance Method Details

#[](item_name) ⇒ String?

Returns the value for the item with the specified name in this header, or ‘nil` if no item with the specified name was part of this header.

Parameters:

  • item_name (String)

    The name of the item to return the header value for.

Returns:

  • (String, nil)

    The value of the item as specified in this header, or ‘nil` if the item name was not specified in this header.



42
43
44
# File 'lib/lightstreamer/stream_connection_header.rb', line 42

def [](item_name)
  @data[item_name]
end

#process_line(line) ⇒ Boolean

Processes a single line of header information. The return value indicates whether further data is required in order to complete the header.

Parameters:

  • line (String)

    The line of header data to process.

Returns:

  • (Boolean)

    Whether the header is still incomplete and requires further data.



24
25
26
27
28
29
30
31
32
33
# File 'lib/lightstreamer/stream_connection_header.rb', line 24

def process_line(line)
  @lines << line

  return process_success if @lines.first == 'OK'
  return process_error if @lines.first == 'ERROR'
  return process_end if @lines.first == 'END'
  return process_sync_error if @lines.first == 'SYNC ERROR'

  process_unrecognized
end