Class: Interpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/javonet-ruby-sdk/core/interpreter/interpreter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/interpreter/interpreter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/interpreter/interpreter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/interpreter/interpreter.rb

Instance Method Summary collapse

Instance Method Details

#execute(command, connection_type, tcp_address) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/javonet-ruby-sdk/core/interpreter/interpreter.rb', line 6

def execute(command, connection_type, tcp_address)

  command_serializer = CommandSerializer.new
  message_byte_array = command_serializer.serialize(command, connection_type, tcp_address)
  if command.runtime_name == RuntimeName::RUBY
    require_relative '../receiver/receiver'
    response_byte_array = Receiver.new.send_command(message_byte_array, message_byte_array.length)
  else
    require_relative '../transmitter/transmitter'
    response_byte_array = Transmitter.send_command(message_byte_array, message_byte_array.length)
  end

  command_deserializer = CommandDeserializer.new(response_byte_array,response_byte_array.length)
  encoded_response = command_deserializer.deserialize
  return encoded_response
end

#process(byte_array, byte_array_len) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/javonet-ruby-sdk/core/interpreter/interpreter.rb', line 23

def process(byte_array, byte_array_len)
  command_deserializer = CommandDeserializer.new(byte_array,byte_array_len)
  received_command = command_deserializer.deserialize
  handler = Handler.new
  command_serializer = CommandSerializer.new
  return command_serializer.serialize(handler.handle_command(received_command), 0, "0.0.0.0:0")
end