Class: LogStash::Inputs::Tcp::DecoderImpl

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/tcp/decoder_impl.rb

Instance Method Summary collapse

Constructor Details

#initialize(codec, tcp) ⇒ DecoderImpl

Returns a new instance of DecoderImpl.



8
9
10
11
12
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 8

def initialize(codec, tcp)
  @tcp = tcp
  @codec = codec
  @first_read = true
end

Instance Method Details

#copyObject



27
28
29
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 27

def copy
  self.class.new(@codec.clone, @tcp)
end

#decode(ctx, data) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 14

def decode(ctx, data)
  channel = ctx.channel()
  bytes = Java::byte[data.readableBytes].new
  data.getBytes(0, bytes)
  data.release
  tbuf = String.from_java_bytes bytes, "ASCII-8BIT"
  if @first_read
    tbuf = init_first_read(channel, tbuf)
  end
  @tcp.decode_buffer(@ip_address, @address, @port, @codec,
                       @proxy_address, @proxy_port, tbuf, @sslsubject)
end

#flushObject



31
32
33
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 31

def flush
  @tcp.flush_codec(@codec, @ip_address, @address, @port, @sslsubject)
end