Module: Bones::RPC::Protocol::MessagePackExtended::BonesRPC

Extended by:
BonesRPC
Included in:
BonesRPC
Defined in:
lib/bones/rpc/protocol.rb

Constant Summary collapse

MAP =
{
  [0].pack('C').freeze => Synchronize,
  [1].pack('C').freeze => Acknowledge
}.freeze

Instance Method Summary collapse

Instance Method Details

#deserialize(buffer, adapter = nil) ⇒ Object


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/bones/rpc/protocol.rb', line 74

def deserialize(buffer, adapter = nil)
  ext8 = buffer.getc
  len = buffer.getc
  type = buffer.getc
  head = buffer.getc
  buffer.ungetc(head)
  buffer.ungetc(type)
  buffer.ungetc(len)
  buffer.ungetc(ext8)
  if sub = MAP[head]
    sub.deserialize(buffer, adapter)
  else
    raise NotImplementedError, "Unknown BonesRPC data received: {ext8: #{ext8.inspect}, len: #{len.inspect}, type: #{type.inspect}, head: #{head.inspect}}"
  end
end