Class: Baykit::BayServer::Protocol::CommandPacker

Inherits:
Object
  • Object
show all
Includes:
Util, Util::Reusable
Defined in:
lib/baykit/bayserver/protocol/command_packer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pkt_packer, store) ⇒ CommandPacker

Returns a new instance of CommandPacker.



14
15
16
17
# File 'lib/baykit/bayserver/protocol/command_packer.rb', line 14

def initialize(pkt_packer, store)
  @pkt_packer = pkt_packer
  @pkt_store = store
end

Instance Attribute Details

#pkt_packerObject (readonly)

Returns the value of attribute pkt_packer.



11
12
13
# File 'lib/baykit/bayserver/protocol/command_packer.rb', line 11

def pkt_packer
  @pkt_packer
end

#pkt_storeObject (readonly)

Returns the value of attribute pkt_store.



12
13
14
# File 'lib/baykit/bayserver/protocol/command_packer.rb', line 12

def pkt_store
  @pkt_store
end

Instance Method Details

#post(sip, cmd, &lisnr) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/baykit/bayserver/protocol/command_packer.rb', line 23

def post(sip, cmd, &lisnr)
  pkt = @pkt_store.rent(cmd.type)
  begin
    cmd.pack(pkt)
    @pkt_packer.post(sip, pkt) do
      @pkt_store.Return(pkt)
      if lisnr != nil
        lisnr.call()
      end
    end
  rescue IOError => e
    @pkt_store.Return(pkt)
    raise e
  end
end

#resetObject



19
20
21
# File 'lib/baykit/bayserver/protocol/command_packer.rb', line 19

def reset()

end