Class: Baykit::BayServer::Protocol::CommandPacker
- Inherits:
 - 
      Object
      
        
- Object
 - Baykit::BayServer::Protocol::CommandPacker
 
 
- Includes:
 - Util, Util::Reusable
 
- Defined in:
 - lib/baykit/bayserver/protocol/command_packer.rb
 
Instance Attribute Summary collapse
- 
  
    
      #pkt_packer  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute pkt_packer.
 - 
  
    
      #pkt_store  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute pkt_store.
 
Instance Method Summary collapse
- 
  
    
      #initialize(pkt_packer, store)  ⇒ CommandPacker 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of CommandPacker.
 - #post(sip, cmd, &lisnr) ⇒ Object
 - #reset ⇒ Object
 
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_packer ⇒ Object (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_store ⇒ Object (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  | 
  
#reset ⇒ Object
      19 20 21  | 
    
      # File 'lib/baykit/bayserver/protocol/command_packer.rb', line 19 def reset() end  |