Class: Baykit::BayServer::Docker::Fcgi::Command::InOutCommandBase

Inherits:
FcgCommand
  • Object
show all
Defined in:
lib/baykit/bayserver/docker/fcgi/command/in_out_command_base.rb

Direct Known Subclasses

CmdStdErr, CmdStdIn, CmdStdOut

Constant Summary collapse

MAX_DATA_LEN =
FcgPacket::MAXLEN - FcgPacket::PREAMBLE_SIZE

Instance Attribute Summary collapse

Attributes inherited from FcgCommand

#req_id

Instance Method Summary collapse

Methods inherited from FcgCommand

#pack_header

Constructor Details

#initialize(type, req_id, data = nil, start = 0, len = 0) ⇒ InOutCommandBase

Returns a new instance of InOutCommandBase.



28
29
30
31
32
33
# File 'lib/baykit/bayserver/docker/fcgi/command/in_out_command_base.rb', line 28

def initialize(type, req_id, data=nil, start=0, len=0)
  super(type, req_id)
  @data = data
  @start = start
  @length = len
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



26
27
28
# File 'lib/baykit/bayserver/docker/fcgi/command/in_out_command_base.rb', line 26

def data
  @data
end

#lengthObject (readonly)

Returns the value of attribute length.



25
26
27
# File 'lib/baykit/bayserver/docker/fcgi/command/in_out_command_base.rb', line 25

def length
  @length
end

#startObject (readonly)

This class refers external byte array, so this IS NOT mutable



24
25
26
# File 'lib/baykit/bayserver/docker/fcgi/command/in_out_command_base.rb', line 24

def start
  @start
end

Instance Method Details

#pack(pkt) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/baykit/bayserver/docker/fcgi/command/in_out_command_base.rb', line 42

def pack(pkt)
  if @data != nil && @length > 0
    acc = pkt.new_data_accessor()
    acc.put_bytes(@data, @start, @length)
  end

  # must be called from last line
  super
end

#unpack(pkt) ⇒ Object



35
36
37
38
39
40
# File 'lib/baykit/bayserver/docker/fcgi/command/in_out_command_base.rb', line 35

def unpack(pkt)
  super
  @start = pkt.header_len
  @length = pkt.data_len
  @data = pkt.buf
end