Class: Lightstreamer::StreamConnectionHeader
- Inherits:
-
Object
- Object
- Lightstreamer::StreamConnectionHeader
- 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
-
#error ⇒ LightstreamerError?
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.
Instance Method Summary collapse
-
#[](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.
-
#initialize ⇒ StreamConnectionHeader
constructor
A new instance of StreamConnectionHeader.
-
#process_line(line) ⇒ Boolean
Processes a single line of header information.
Constructor Details
#initialize ⇒ StreamConnectionHeader
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
#error ⇒ LightstreamerError? (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.
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.
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.
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 |