Class: Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/javonet-ruby-sdk/core/receiver/receiver_new.rb

Instance Method Summary collapse

Constructor Details

#initializeReceiver

Returns a new instance of Receiver.



9
10
11
# File 'lib/javonet-ruby-sdk/core/receiver/receiver_new.rb', line 9

def initialize
  puts get_runtime_info
end

Instance Method Details

#get_runtime_infoObject



38
39
40
# File 'lib/javonet-ruby-sdk/core/receiver/receiver_new.rb', line 38

def get_runtime_info
  RuntimeLogger.get_runtime_info(true)
end

#heart_beat(message_array) ⇒ Object



33
34
35
36
# File 'lib/javonet-ruby-sdk/core/receiver/receiver_new.rb', line 33

def heart_beat(message_array)
  response_array = [49, 48]
  [response_array.length, response_array]
end

#send_command(message_array) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/javonet-ruby-sdk/core/receiver/receiver_new.rb', line 13

def send_command(message_array)
  begin
    response_array = CommandSerializer.new.serialize(Interpreter.new.process(message_array))
  rescue Exception => e
    message = "Error occurred in Javonet Ruby Core: #{e.message}"
    puts message
    exception_command = Command.new(RuntimeNameJavonet::RUBY, CommandType::EXCEPTION, [])
    exception_command = exception_command.add_arg_to_payload(ExceptionType::EXCEPTION)
    exception_command = exception_command.add_arg_to_payload(Command.new(RuntimeNameJavonet::RUBY, CommandType::EXCEPTION, ["Ruby Core Error", "Ruby Core Error"]).to_string)
    exception_command = exception_command.add_arg_to_payload("Ruby Core Error")
    exception_command = exception_command.add_arg_to_payload(e.message)
    exception_command = exception_command.add_arg_to_payload("Receiver")
    exception_command = exception_command.add_arg_to_payload("send_command")
    exception_command = exception_command.add_arg_to_payload("undefined")
    exception_command = exception_command.add_arg_to_payload(__FILE__)
    response_array = CommandSerializer.new.serialize(exception_command)
  end
    [response_array.length, response_array]
end