Class: Http2Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection_data) ⇒ Http2Client

Returns a new instance of Http2Client.



61
62
63
64
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 61

def initialize(connection_data)
  @connection_data = connection_data
  @send_receive_lock = Mutex.new
end

Class Method Details

.close(connection_data) ⇒ Object



20
21
22
23
24
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 20

def close(connection_data)
  @clients_lock.synchronize do
    @clients.delete(connection_key(connection_data))
  end
end

.get_state(connection_data) ⇒ Object



26
27
28
29
30
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 26

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

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 8

def send_message(connection_data, message)
  raise ArgumentError, 'connection_data cannot be nil' if connection_data.nil?
  raise ArgumentError, 'message cannot be nil' if message.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_lockObject



66
67
68
# File 'lib/hypertube-ruby-sdk/core/http2_client/http2_client.rb', line 66

def with_send_receive_lock
  @send_receive_lock.synchronize { yield }
end