Sha256: c1ada5527351879bde8c2b4f1179fba0d3903dc337501f7d2598346d163dc8c4
Contents?: true
Size: 1.13 KB
Versions: 12
Compression:
Stored size: 1.13 KB
Contents
# -*- encoding: utf-8 -*- # A simple encapsulation of a subscription. Instances of this class keep # track of the SUBSCRIBE frame they were generated for and the callback to # invoke when a MESSAGE frame is received for the subscription. class OnStomp::Components::Subscription attr_reader :frame, :callback # Creates a new subscription # @param [OnStomp::Components::Frame] fr the subscription's SUBSCRIBE frame # @param [Proc] cb the subscription's callback def initialize(fr, cb) @frame = fr @callback = cb end # Returns the `id` header of the associated SUBSCRIBE frame # @return [String] def id; frame[:id]; end # Returns the `destination` header of the associated SUBSCRIBE frame # @return [String] def destination; frame[:destination]; end # Invokes the {#callback}, passing along the supplied MESSAGE frame # @param [OnStomp::Componenets::Frame] m the associated MESSAGE frame def call(m); callback.call(m); end # Returns true if this message frame shares the same destination as this # subscription, false otherwise. # @return [true, false] def include? m self.destination == m[:destination] end end
Version data entries
12 entries across 12 versions & 1 rubygems