class Qpid::Proton::Handler::EndpointStateHandler

A utility that exposes endpoint events; i.e., the open/close of a link, session or connection, in a more intuitive manner.

A XXX_opened method will be called when both local and remote peers have opened the link, session or connection. This can be used to confirm a locally initiated action for example.

A XXX_opening method will be called when the remote peer has requested an open that was not initiated locally. By default this will simply open locally, which then trigtgers the XXX_opened called.

The same applies to close.

Public Class Methods

new(peer_close_is_error = false, delegate = nil) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 37
def initialize(peer_close_is_error = false, delegate = nil)
  @delegate = delegate
  @peer_close_is_error = peer_close_is_error
end
print_error(endpoint, endpoint_type) click to toggle source

Public Instance Methods

on_connection_closed(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 171
def on_connection_closed(event)
  Qpid::Proton::Event.dispatch(@delegate, :on_connection_closed, event) if !@delegate.nil?
end
on_connection_closing(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 183
def on_connection_closing(event)
  if !@delegate.nil?
    Qpid::Proton::Event.dispatch(@delegate, :on_connection_closing, event)
  elsif @peer_close_is_error
    self.on_connection_error(event)
  end
end
on_connection_error(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 145
def on_connection_error(event)
  if !@delegate.nil?
    Qpid::Proton::Event.dispatch(@delegate, :on_connection_error, event)
  else
    self.log_error(event.connection, "connection")
  end
end
on_connection_local_open(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 82
def on_connection_local_open(event)
  self.on_connection_opened(event) if event.connection.remote_active?
end
on_connection_opened(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 121
def on_connection_opened(event)
  Qpid::Proton::Event.dispatch(@delegate, :on_connection_opened, event) if !@delegate.nil?
end
on_connection_opening(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 133
def on_connection_opening(event)
  Qpid::Proton::Event.dispatch(@delegate, :on_connection_opening, event) if !@delegate.nil?
end
on_connection_remote_close(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 71
def on_connection_remote_close(event)
  if !event.connection.remote_condition.nil?
    self.on_connection_error(event)
  elsif event.connection.local_closed?
    self.on_connection_closed(event)
  else
    self.on_connection_closing(event)
  end
  event.connection.close
end
on_connection_remote_open(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 86
def on_connection_remote_open(event)
  if !(event.connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
    self.on_connection_opened(event)
  elsif event.connection.local_uninit?
    self.on_connection_opening(event)
    event.connection.open
  end
end
on_session_closed(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 175
def on_session_closed(event)
  Qpid::Proton::Event.dispatch(@delegate, :on_session_closed, event) if !@delegate.nil?
end
on_session_closing(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 191
def on_session_closing(event)
  if !@delegate.nil?
    Qpid::Proton::Event.dispatch(@delegate, :on_session_closing, event)
  elsif @peer_close_is_error
    self.on_session_error(event)
  end
end
on_session_error(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 153
def on_session_error(event)
  if !@delegate.nil?
    Qpid::Proton::Event.dispatch(@delegate, :on_session_error, event)
  else
    self.log_error(event.session, "session")
    event.connection.close
  end
end
on_session_local_open(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 95
def on_session_local_open(event)
  self.on_session_opened(event) if event.session.remote_active?
end
on_session_opened(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 125
def on_session_opened(event)
  Qpid::Proton::Event.dispatch(@delegate, :on_session_opened, event) if !@delegate.nil?
end
on_session_opening(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 137
def on_session_opening(event)
  Qpid::Proton::Event.dispatch(@delegate, :on_session_opening, event) if !@delegate.nil?
end
on_session_remote_close(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 60
def on_session_remote_close(event)
  if !event.session.remote_condition.nil?
    self.on_session_error(event)
  elsif event.session.local_closed?
    self.on_session_closed(event)
  else
    self.on_session_closing(event)
  end
  event.session.close
end
on_session_remote_open(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 99
def on_session_remote_open(event)
  if !(event.session.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
    self.on_session_opened(event)
  elsif event.session.local_uninit?
    self.on_session_opening(event)
    event.session.open
  end
end
on_transport_closed(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 211
def on_transport_closed(event)
  Qpid::Proton::Event.dispatch(@delegate, :on_disconnected, event) if !@delegate.nil?
end
on_transport_tail_closed(event) click to toggle source
# File lib/handler/endpoint_state_handler.rb, line 207
def on_transport_tail_closed(event)
  self.on_transport_closed(event)
end