9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/hypertube-ruby-sdk/core/interpreter/interpreter.rb', line 9
def self.execute(command, connection_type, connection_data)
message_byte_array = Hypertube::Core::Protocol::CommandSerializer.serialize(command, connection_data)
if connection_type == Hypertube::Utils::ConnectionType::WEB_SOCKET
require_relative '../web_socket_client/web_socket_client'
response_byte_array = Hypertube::Core::WebSocketClient::WebSocketClient.send_message(connection_data, message_byte_array)
elsif connection_type == Hypertube::Utils::ConnectionType::HTTP2
require_relative '../http2_client/http2_client'
response_byte_array = Hypertube::Core::Http2Client::Http2Client.send_message(connection_data, message_byte_array)
elsif command.runtime_name == Hypertube::Utils::RuntimeNameHt::RUBY && connection_type == Hypertube::Utils::ConnectionType::IN_MEMORY
require_relative '../receiver/receiver'
response_byte_array = Hypertube::Core::Receiver::Receiver.send_command(message_byte_array)[1]
else
require_relative '../transmitter/transmitter'
response_byte_array = Hypertube::Core::Transmitter::Transmitter.send_command(message_byte_array, message_byte_array.length)
end
Hypertube::Core::Protocol::CommandDeserializer.new(response_byte_array).deserialize
end
|