Class: HeartBeatExample1

### Home Classes Methods

### In Files

- examples/conn11_hb1.rb

### Parent

Object

### Methods

- ::new
- #run

### Files

- CHANGELOG.rdoc
- LICENSE

### Class/Module Index

Quicksearch

- Stomp
- Stomp::Client
- Stomp::Connection
- Stomp::Error
- Stomp::Error::ConnectReadTimeout
- Stomp::Error::DuplicateSubscription
- Stomp::Error::InvalidFormat
- Stomp::Error::InvalidHeartBeatHeaderError
- Stomp::Error::InvalidMessageLength
- Stomp::Error::InvalidServerCommand
- Stomp::Error::LoggerConnectionError
- Stomp::Error::MalformedFailoverOptionsError
- Stomp::Error::MaxReconnectAttempts
- Stomp::Error::MessageIDRequiredError
- Stomp::Error::NilMessageError
- Stomp::Error::NoCurrentConnection
- Stomp::Error::PacketParsingTimeout
- Stomp::Error::ProtocolError11p
- Stomp::Error::ProtocolErrorConnect
- Stomp::Error::SSLClientParamsError
- Stomp::Error::SSLNoCertFileError
- Stomp::Error::SSLNoKeyFileError
- Stomp::Error::SSLNoTruststoreFileError
- Stomp::Error::SSLUnreadableCertFileError
- Stomp::Error::SSLUnreadableKeyFileError
- Stomp::Error::SSLUnreadableTruststoreFileError
- Stomp::Error::SocketOpenTimeout
- Stomp::Error::StompServerError
- Stomp::Error::SubscriptionRequiredError
- Stomp::Error::UTF8ValidationError
- Stomp::Error::UnsupportedProtocolError
- Stomp::HeaderCodec
- Stomp::Message
- Stomp::SSLParams
- Client11Example1
- Client11PutGet1
- Connection11Example1
- Connection11Example2
- ExampleConsumer
- ExamplePublisher
- ExampleRubyCiphers
- ExampleSSL1
- ExampleSSL1C
- ExampleSSL2
- ExampleSSL2C
- ExampleSSL3
- ExampleSSL3C
- ExampleSSL4
- ExampleSSL4C
- ExampleTopicConsumer
- ExampleTopicPublisher
- Hash
- HeartBeatExample1
- LoggerExample
- Object
- Publish11Example1
- Receive11Example1
- Receive11Example2
- RepeatedHeadersExample
- SSLLoggerExample
- Slogger
- Stomp11Common
- TestBase
- TestClient
- TestConnection
- TestConnection1P
- TestMessage
- TestSSL
- TestURLLogins
- Tlogger

No matching classes.

# 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.