Class: OnStomp::Connections::Stomp_1_1
- Includes:
- Heartbeating, Stomp_1
- Defined in:
- lib/onstomp/connections/stomp_1_1.rb
Overview
A STOMP 1.1 specific connection
Constant Summary
Constants inherited from Base
Base::MAX_BYTES_PER_READ, Base::MAX_BYTES_PER_WRITE
Instance Attribute Summary collapse
Attributes included from Heartbeating
Attributes inherited from Base
#client, #last_received_at, #last_transmitted_at, #read_timeout, #socket, #version, #write_timeout
Instance Method Summary collapse
-
#ack_frame(*args) ⇒ OnStomp::Components::Frame
Creates an ACK frame.
-
#configure(connected, con_cbs) ⇒ Object
Calls Base#configure then configures heartbeating parameters.
-
#connected? ⇒ Boolean
Returns true if Base#connected? is true and we have a Heartbeating#pulse?.
-
#heartbeat_frame ⇒ OnStomp::Components::Frame
Creates a heartbeat frame (serialized as a single "\n" character).
-
#initialize(socket, client) ⇒ Stomp_1_1
constructor
Calls Base#initialize and creates a STOMP 1.0 serializer.
-
#nack_frame(*args) ⇒ OnStomp::Components::Frame
Creates an NACK frame.
-
#subscribe_frame(d, h) ⇒ OnStomp::Components::Frame
Creates a SUBSCRIBE frame.
Methods included from Heartbeating
#broker_pulse?, #client_pulse?, #configure_heartbeating, #heartbeat_broker_limit, #heartbeat_client_limit, #pulse?
Methods included from Stomp_1
#abort_frame, #begin_frame, #commit_frame, #connect_frame, #disconnect_frame, #send_frame, #unsubscribe_frame
Methods inherited from Base
#close, #connect, #duration_since_received, #duration_since_transmitted, #flush_write_buffer, #io_process, #io_process_read, #io_process_write, #method_missing, #push_write_buffer, #shift_write_buffer, #unshift_write_buffer, #write_frame_nonblock
Methods included from Interfaces::ConnectionEvents
#install_bindings_from_client, #trigger_connection_event
Methods included from Interfaces::EventManager
#bind_event, #event_callbacks, included, #trigger_event
Constructor Details
#initialize(socket, client) ⇒ Stomp_1_1
Calls Base#initialize and creates a STOMP 1.0 serializer
14 15 16 17 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 14 def initialize socket, client super @serializer = OnStomp::Connections::Serializers::Stomp_1_1.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OnStomp::Connections::Base
Instance Attribute Details
#serializer ⇒ OnStomp::Connections::Serializers::Stomp_1_1 (readonly)
10 11 12 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 10 def serializer @serializer end |
Instance Method Details
#ack_frame(*args) ⇒ OnStomp::Components::Frame
Creates an ACK frame
44 45 46 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 44 def ack_frame *args create_ack_or_nack 'ACK', args end |
#configure(connected, con_cbs) ⇒ Object
Calls Base#configure then configures heartbeating parameters.
23 24 25 26 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 23 def configure connected, con_cbs super configure_heartbeating client.heartbeats, connected.heart_beat end |
#connected? ⇒ Boolean
Returns true if Base#connected? is true and we have a Heartbeating#pulse?
30 31 32 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 30 def connected? super && pulse? end |
#heartbeat_frame ⇒ OnStomp::Components::Frame
Creates a heartbeat frame (serialized as a single "\n" character)
56 57 58 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 56 def heartbeat_frame OnStomp::Components::Frame.new end |
#nack_frame(*args) ⇒ OnStomp::Components::Frame
Creates an NACK frame
50 51 52 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 50 def nack_frame *args create_ack_or_nack 'NACK', args end |
#subscribe_frame(d, h) ⇒ OnStomp::Components::Frame
Creates a SUBSCRIBE frame. Sets ack
header to 'auto' unless it is
already set to 'client' or 'client-individual'.
37 38 39 40 |
# File 'lib/onstomp/connections/stomp_1_1.rb', line 37 def subscribe_frame d, h h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack]) create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}] end |