Sha256: 3246a2c60e18475191bd8f7561441517d0e63c35666237c360eb5c007e7f4a33

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

module Stomper
  module Frames
    # Encapsulates an "ACK" frame from the Stomp Protocol.
    #
    # See the {Stomp Protocol Specification}[http://stomp.codehaus.org/Protocol]
    # for more details.
    class Ack < Stomper::Frames::ClientFrame
      def initialize(message_id, headers={})
        super('ACK', headers)
        @headers["message-id"] = message_id
      end

      # Creates a new Ack instance that corresponds to an acknowledgement
      # of the supplied +message+, with any additional +headers+.  The
      # +message+ parameter may be an instance of Stomper::Frames::Message, or
      # a message id.  If +message+ is an instance of Stomper::Frames::Message
      # and was exchanged as part of a transaction, the transaction header from
      # +message+ will be injected into the newly created Ack object's headers.
      def self.ack_for(message, headers = {})
        if message.is_a?(Message)
          headers['transaction'] = message.headers.transaction if message.headers.transaction
          new(message.id, headers)
        else
          new(message.to_s)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stomper-0.4 lib/stomper/frames/ack.rb
stomper-0.3.2 lib/stomper/frames/ack.rb
stomper-0.3.1 lib/stomper/frames/ack.rb
stomper-0.3.0 lib/stomper/frames/ack.rb