Class: OnStomp::Connections::Stomp_1_0

Inherits:
Base
  • Object
show all
Includes:
Stomp_1
Defined in:
lib/onstomp/connections/stomp_1_0.rb

Overview

A STOMP 1.0 specific connection

Constant Summary

Constants inherited from Base

MAX_BYTES_PER_READ, MAX_BYTES_PER_WRITE

Instance Attribute Summary (collapse)

Attributes inherited from Base

client, last_received_at, last_transmitted_at, read_timeout, socket, version, write_timeout

Instance Method Summary (collapse)

Methods included from Stomp_1

#abort_frame, #begin_frame, #commit_frame, #connect_frame, #disconnect_frame, #send_frame, #unsubscribe_frame

Methods inherited from Base

#close, #configure, #connect, #connected?, #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

#blocked, #closed, #died, #established, #install_bindings_from_client, #on_blocked, #on_closed, #on_died, #on_established, #on_terminated, #terminated, #trigger_connection_event

Methods included from Interfaces::EventManager

#bind_event, #event_callbacks, included, #trigger_event

Constructor Details

- (Stomp_1_0) initialize(socket, client)

Calls Base#initialize and creates a STOMP 1.0 serializer



13
14
15
16
# File 'lib/onstomp/connections/stomp_1_0.rb', line 13

def initialize socket, client
  super
  @serializer = OnStomp::Connections::Serializers::Stomp_1_0.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OnStomp::Connections::Base

Instance Attribute Details

- (OnStomp::Connections::Serializers::Stomp_1_0) serializer (readonly)

The serializer that will convert frames into raw bytes and will convert raw bytes into frames



9
10
11
# File 'lib/onstomp/connections/stomp_1_0.rb', line 9

def serializer
  @serializer
end

Instance Method Details

- (OnStomp::Components::Frame) ack_frame(*args)

Creates an ACK frame

Returns:



28
29
30
31
32
33
34
35
# File 'lib/onstomp/connections/stomp_1_0.rb', line 28

def ack_frame *args
  headers = args.last.is_a?(Hash) ? args.pop : {}
  m_id = args.shift
  m_id = m_id[:message-id'] if m_id.is_a?(OnStomp::Components::Frame)
  create_frame('ACK', [{:message-id' => m_id}, headers]).tap do |f|
    raise ArgumentError, 'no message-id to ACK' unless f.header?(:message-id')
  end
end

- (OnStomp::Components::Frame) subscribe_frame(d, h)

Creates a SUBSCRIBE frame. Sets ack header to 'auto' unless it is already set to 'client'.

Returns:



21
22
23
24
# File 'lib/onstomp/connections/stomp_1_0.rb', line 21

def subscribe_frame d, h
  h[:ack] = 'auto' unless h[:ack] == 'client'
  create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]
end