Module: OnStomp::Interfaces::ClientEvents
Overview
Mixin for client events There are a few special event methods that will be passed on to the client's connection, they are:
on_connection_established
=> OnStomp::Interfaces::ConnectionEvents#on_establishedon_connection_died
=> OnStomp::Interfaces::ConnectionEvents#on_diedon_connection_terminated
=> OnStomp::Interfaces::ConnectionEvents#on_terminatedon_connection_closed
=> OnStomp::Interfaces::ConnectionEvents#on_closed
Instance Method Summary collapse
-
#pending_connection_events ⇒ {Symbol => Array<Proc>}
Returns a hash of event bindings that should be set on a connection, but were set on the client because the connection does not exist yet.
-
#trigger_after_receiving(f) ⇒ Object
Triggers the :after_receiving event and the
on
prefixed frame specific event (eg::on_message
). -
#trigger_after_transmitting(f) ⇒ Object
Triggers the :after_transmitting event and the
on
prefixed frame specific event (eg::on_send
). -
#trigger_before_receiving(f) ⇒ Object
Triggers the :before_receiving event and the
before
prefixed frame specific event (eg::before_error
). -
#trigger_before_transmitting(f) ⇒ Object
Triggers the :before_transmitting event and the
before
prefixed frame specific event (eg::before_disconnect
). -
#trigger_frame_event(f, pref, origin) ⇒ Object
Triggers an event named by the supplied frame, prefixed with the supplied prefix.
Methods included from EventManager
#bind_event, #event_callbacks, included, #trigger_event
Instance Method Details
#pending_connection_events ⇒ {Symbol => Array<Proc>}
Returns a hash of event bindings that should be set on a connection, but were set on the client because the connection does not exist yet.
144 145 146 |
# File 'lib/onstomp/interfaces/client_events.rb', line 144 def pending_connection_events @pending_connection_events ||= Hash.new { |h,k| h[k] = [] } end |
#trigger_after_receiving(f) ⇒ Object
Triggers the :after_receiving event and the
on
prefixed frame specific event (eg: :on_message
)
171 172 173 174 |
# File 'lib/onstomp/interfaces/client_events.rb', line 171 def trigger_after_receiving f trigger_event :after_receiving, f, self trigger_frame_event f, :on, :broker end |
#trigger_after_transmitting(f) ⇒ Object
Triggers the :after_transmitting event and the
on
prefixed frame specific event (eg: :on_send
).
187 188 189 190 |
# File 'lib/onstomp/interfaces/client_events.rb', line 187 def trigger_after_transmitting f trigger_event :after_transmitting, f, self trigger_frame_event f, :on, :client end |
#trigger_before_receiving(f) ⇒ Object
Triggers the :before_receiving event and the
before
prefixed frame specific event (eg: :before_error
).
163 164 165 166 |
# File 'lib/onstomp/interfaces/client_events.rb', line 163 def trigger_before_receiving f trigger_event :before_receiving, f, self trigger_frame_event f, :before, :broker end |
#trigger_before_transmitting(f) ⇒ Object
Triggers the :before_transmitting event and the
before
prefixed frame specific event (eg: :before_disconnect
).
179 180 181 182 |
# File 'lib/onstomp/interfaces/client_events.rb', line 179 def trigger_before_transmitting f trigger_event :before_transmitting, f, self trigger_frame_event f, :before, :client end |
#trigger_frame_event(f, pref, origin) ⇒ Object
Triggers an event named by the supplied frame, prefixed with the supplied prefix. If the supplied frame is a 'heart-beat', origin will be used to dispatch appropriate heart-beat event (client_beat or broker_beat)
154 155 156 157 158 |
# File 'lib/onstomp/interfaces/client_events.rb', line 154 def trigger_frame_event f, pref, origin e = f.command ? :"#{pref}_#{f.command.downcase}" : :"#{pref}_#{origin}_beat" trigger_event e, f, self end |