Module: OnStomp::Interfaces::ConnectionEvents
- Includes:
- EventManager
- Included in:
- Connections::Base
- Defined in:
- lib/onstomp/interfaces/connection_events.rb
Overview
Mixin for connection events
Instance Method Summary collapse
-
#install_bindings_from_client(ev_hash) ⇒ Object
Takes a hash of event bindings a client has stored and binds them to this connection, then triggers
on_established
. -
#trigger_connection_event(event, msg = '') ⇒ Object
Triggers a connection specific event.
Methods included from EventManager
#bind_event, #event_callbacks, included, #trigger_event
Instance Method Details
#install_bindings_from_client(ev_hash) ⇒ Object
Takes a hash of event bindings a client has stored
and binds them to this connection, then triggers on_established
.
This allows users to add callbacks for
connection events before the connection exist and have said callbacks
installed once the connection is created.
68 69 70 71 72 73 |
# File 'lib/onstomp/interfaces/connection_events.rb', line 68 def install_bindings_from_client ev_hash ev_hash.each do |ev, cbs| cbs.each { |cb| bind_event(ev, cb) } end trigger_connection_event :established, "STOMP #{self.version} connection negotiated" end |
#trigger_connection_event(event, msg = '') ⇒ Object
Triggers a connection specific event.
57 58 59 |
# File 'lib/onstomp/interfaces/connection_events.rb', line 57 def trigger_connection_event event, msg='' trigger_event :"on_#{event}", self.client, self, msg end |