Class: Hypertube::Core::Http2Client::Http2Client
- Inherits:
-
Object
- Object
- Hypertube::Core::Http2Client::Http2Client
- Defined in:
- lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb
Class Method Summary collapse
- .close(connection_data) ⇒ Object
- .get_state(connection_data) ⇒ Object
- .send_message(connection_data, message) ⇒ Object
Instance Method Summary collapse
-
#initialize(connection_data) ⇒ Http2Client
constructor
A new instance of Http2Client.
- #with_send_receive_lock ⇒ Object
Constructor Details
#initialize(connection_data) ⇒ Http2Client
Returns a new instance of Http2Client.
64 65 66 67 |
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 64 def initialize(connection_data) @connection_data = connection_data @send_receive_lock = Mutex.new end |
Class Method Details
.close(connection_data) ⇒ Object
23 24 25 26 27 |
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 23 def close(connection_data) @clients_lock.synchronize do @clients.delete(connection_key(connection_data)) end end |
.get_state(connection_data) ⇒ Object
29 30 31 32 33 |
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 29 def get_state(connection_data) @clients_lock.synchronize do @clients.key?(connection_key(connection_data)) ? :OPEN : nil end end |
.send_message(connection_data, message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 11 def (connection_data, ) raise ArgumentError, 'connection_data cannot be nil' if connection_data.nil? raise ArgumentError, 'message cannot be nil' if .nil? client = create_or_get_client(connection_data, expected_current: nil) client.with_send_receive_lock do # TODO: Use framework HTTP/2 client in a later step. # Keep this client as skeleton for now. return [] end end |
Instance Method Details
#with_send_receive_lock ⇒ Object
69 70 71 |
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 69 def with_send_receive_lock @send_receive_lock.synchronize { yield } end |