Module: Bones::RPC::Protocol

Extended by:
Protocol
Included in:
Protocol
Defined in:
lib/bones/rpc/protocol.rb,
lib/bones/rpc/protocol.rb,
lib/bones/rpc/protocol/notify.rb,
lib/bones/rpc/protocol/request.rb,
lib/bones/rpc/protocol/response.rb,
lib/bones/rpc/protocol/acknowledge.rb,
lib/bones/rpc/protocol/ext_message.rb,
lib/bones/rpc/protocol/synchronize.rb,
lib/bones/rpc/protocol/binary_helper.rb,
lib/bones/rpc/protocol/adapter_helper.rb

Overview

The Bones::RPC::Protocol namespace contains convenience classes for building all of the possible messages defined in the Bones RPC Protocol.

Defined Under Namespace

Modules: AdapterHelper, BinaryHelper, MessagePackExtended Classes: Acknowledge, ExtMessage, Notify, Request, Response, Synchronize

Constant Summary collapse

MAP =
{
  [0xc7].pack('C').freeze => MessagePackExtended
}.freeze

Instance Method Summary collapse

Instance Method Details

#deserialize(buffer, adapter = nil) ⇒ Object


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bones/rpc/protocol.rb', line 42

def deserialize(buffer, adapter = nil)
  char = buffer.getc
  buffer.ungetc(char)
  if sub = MAP[char]
    sub.deserialize(buffer, adapter)
  elsif adapter
    Adapter.get(adapter).deserialize(buffer)
  else
    raise NotImplementedError, "Unknown data received: #{char.inspect}"
  end
end

#get_by_ext_head(head) ⇒ Object


9
10
11
# File 'lib/bones/rpc/protocol.rb', line 9

def get_by_ext_head(head)
  ext_heads[head]
end

#register_ext_head(message, head) ⇒ Object


13
14
15
16
# File 'lib/bones/rpc/protocol.rb', line 13

def register_ext_head(message, head)
  ext_heads[head] ||= message
  return message
end