Parent

Methods

Class/Module Index [+]

Quicksearch

HeartBeatExample1

Stomp 1.1 Heartbeat Example 1

Purpose: to demonstrate that heart beats can work.

Public Class Methods

new() click to toggle source

Initialize.

# File examples/conn11_hb1.rb, line 23
def initialize
end

Public Instance Methods

run() click to toggle source

Run example.

# File examples/conn11_hb1.rb, line 26
def run
  # Create connection headers
  # =========================
  #
  conn_hdrs = {"accept-version" => "1.1", # 1.1
    "host" => virt_host,                  # vhost
    "heart-beat" => "5000,10000",         # heartbeats
  }
  # Create a logger for demonstration purposes
  logger = Slogger.new
  # Connect - a paramaterized request.
  conn = Stomp::Connection.new(login, passcode, host, port,   # Normal connect parms
    false,      # Not reliable, the default for a paramaterized connection
    5,          # Connect redelay, the default for a paramaterized connection
    conn_hdrs)  # The 1.1 connection parameters / headers
  puts "Connection connect complete"
  #
  raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
  #
  conn.set_logger(logger) # Connection uses a logger
  sleep 65
  conn.set_logger(nil)    # No logging
  #
  conn.disconnect   # Get out
  puts "Connection disconnect complete"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.