Class: Isomorfeus::Speednode::Runtime::VMCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/isomorfeus/speednode/runtime.rb

Instance Method Summary collapse

Constructor Details

#initialize(socket, cmd, arguments) ⇒ VMCommand

Returns a new instance of VMCommand.



5
6
7
8
9
# File 'lib/isomorfeus/speednode/runtime.rb', line 5

def initialize(socket, cmd, arguments)
  @socket = socket
  @cmd = cmd
  @arguments = arguments
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
# File 'lib/isomorfeus/speednode/runtime.rb', line 11

def execute
  result = ''
  message = ::Oj.dump({ 'cmd' => @cmd, 'args' => @arguments }, mode: :strict)
  @socket.sendmsg(message + "\x04")
  begin
    result << @socket.recvmsg()[0]
  end until result.end_with?("\x04")
  ::Oj.load(result.chop!, create_additions: false)
end