Class: Hypertube::Core::Http2Client::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.



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

Raises:

  • (ArgumentError)


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 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



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