Class: Hypertube::Core::Protocol::CommandDeserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/hypertube-ruby-sdk/core/protocol/command_deserializer.rb

Class Method Summary collapse

Class Method Details

.deserialize(buffer) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hypertube-ruby-sdk/core/protocol/command_deserializer.rb', line 14

def self.deserialize(buffer)
  state = { buffer: buffer, position: 11 }
  runtime_name = buffer[0]
  command_type = buffer[10]
  payload = []

  while state[:position] < buffer.length
    payload << read_object(state, buffer[state[:position]])
  end

  Hypertube::Utils::Command.new(runtime_name, command_type, payload)
end