Class: WsConnectionData
- Inherits:
-
Object
- Object
- WsConnectionData
- Defined in:
- lib/hypertube-ruby-sdk/utils/ws_connection_data.rb
Constant Summary collapse
- DEFAULT_CONNECT_TIMEOUT_SECONDS =
60
Instance Attribute Summary collapse
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
Instance Method Summary collapse
- #add_header(key, value) ⇒ Object
- #add_headers(headers) ⇒ Object
- #connection_type ⇒ Object
- #headers ⇒ Object
-
#initialize(hostname, connect_timeout = DEFAULT_CONNECT_TIMEOUT_SECONDS) ⇒ WsConnectionData
constructor
A new instance of WsConnectionData.
- #serialize_connection_data ⇒ Object
- #to_canonical_key ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hostname, connect_timeout = DEFAULT_CONNECT_TIMEOUT_SECONDS) ⇒ WsConnectionData
Returns a new instance of WsConnectionData.
8 9 10 11 12 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 8 def initialize(hostname, connect_timeout = DEFAULT_CONNECT_TIMEOUT_SECONDS) @hostname = hostname @connect_timeout = connect_timeout @headers = {} end |
Instance Attribute Details
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
6 7 8 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 6 def connect_timeout @connect_timeout end |
#hostname ⇒ Object
Returns the value of attribute hostname.
6 7 8 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 6 def hostname @hostname end |
Instance Method Details
#add_header(key, value) ⇒ Object
22 23 24 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 22 def add_header(key, value) @headers[key.to_s] = value.to_s end |
#add_headers(headers) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 26 def add_headers(headers) return if headers.nil? headers.each do |key, value| add_header(key, value) end end |
#connection_type ⇒ Object
14 15 16 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 14 def connection_type ConnectionType::WEB_SOCKET end |
#headers ⇒ Object
18 19 20 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 18 def headers @headers.dup end |
#serialize_connection_data ⇒ Object
34 35 36 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 34 def serialize_connection_data [connection_type, 0, 0, 0, 0, 0, 0] end |
#to_canonical_key ⇒ Object
42 43 44 45 46 47 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 42 def to_canonical_key headers_for_key = serialize_headers_for_key return to_s if headers_for_key.empty? "#{to_s}|h:#{headers_for_key}" end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/hypertube-ruby-sdk/utils/ws_connection_data.rb', line 38 def to_s "websocket|#{@hostname}" end |