Sha256: 78c0077719eb8d09d31af9ae9ea6eb0f44ae06737c9b36632be3da77b8be7460

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

class FluQ::Input::Socket::Connection < EventMachine::Connection
  include FluQ::Mixins::Loggable

  # Constructor
  # @param [FluQ::Input::Socket] parent the input
  def initialize(parent)
    super()
    @parent = parent
  end

  # Callback
  def post_init
    self.comm_inactivity_timeout = 60
  end

  # Callback
  def receive_data(data)
    buffer.write(data)
    flush! if buffer.full?
  rescue => ex
    logger.crash "#{self.class.name} failure: #{ex.message} (#{ex.class.name})", ex
  end

  # Callback
  def unbind
    flush!
  end

  protected

    def buffer
      @buffer ||= @parent.new_buffer
    end

    def flush!
      current = buffer
      @buffer = nil
      @parent.flush!(current)
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluq-0.7.5 lib/fluq/input/socket/connection.rb
fluq-0.7.3 lib/fluq/input/socket/connection.rb
fluq-0.7.1 lib/fluq/input/socket/connection.rb
fluq-0.7.0 lib/fluq/input/socket/connection.rb