Class: Qpid::Proton::Listener::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/core/listener.rb

Overview

Class that handles listener events and provides options for accepted connections. This class simply returns a fixed set of options for every connection accepted, but you can subclass and override all of the on_ methods to provide more interesting behaviour.

Note: If a Qpid::Proton::Listener method raises an exception, it will stop the Container that the handler is running in. See Container#run

Instance Method Summary collapse

Constructor Details

#initialize(opts = nil) ⇒ Handler

Returns a new instance of Handler.

Parameters:

  • opts (Hash) (defaults to: nil)

    Options to return from on_accept.



37
# File 'lib/core/listener.rb', line 37

def initialize(opts=nil) @opts = opts || {}; end

Instance Method Details

#on_accept(listener) ⇒ Hash

Called when a listener accepts a new connection.

Parameters:

Returns:

  • (Hash)

    Options to apply to the incoming connection, see #connect



53
# File 'lib/core/listener.rb', line 53

def on_accept(listener) @opts; end

#on_close(listener)

Called when the listener closes.

Parameters:

  • listener (Listener)

    The listener accepting the connection.



57
# File 'lib/core/listener.rb', line 57

def on_close(listener) end

#on_error(listener, what)

Called if an error occurs. If there is an error while opening the listener, this method is called and #on_open is not

Parameters:



48
# File 'lib/core/listener.rb', line 48

def on_error(listener, what) end

#on_open(listener)

Called when the listener is ready to accept connections.

Parameters:



41
# File 'lib/core/listener.rb', line 41

def on_open(listener) end