Sha256: 9be91af32d7541dea2c44c98cba082e17f16c9097ca8985167548e1c1cd24b8d

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module Stomper
  module Frames
    # Encapsulates a "MESSAGE" server side frame for the Stomp Protocol.
    class Message < Stomper::Frames::ServerFrame

      # Creates a new message frame with the given +headers+ and +body+
      def initialize(headers, body)
        super(headers, body)
      end

      # Returns the message id generated by the stomp broker.
      #
      # This is a convenience method for:
      # frame.headers[:'message-id']
      def id
        @headers[:'message-id']
      end

      # Returns the destination from which this message was delivered.
      #
      # This is a convenience method for:
      # frame.headers[:destination]
      def destination
        @headers[:destination]
      end

      # Returns the name of the subscription which is responsible for the
      # client having received this message.
      #
      # This is a convenience method for:
      # frame.headers[:subscription]
      def subscription
        @headers[:subscription]
      end

      def perform
        # TODO: I want the frames, particularly the server frames, to know
        # 'what to do' when they are received.  For instance, when a MESSAGE
        # frame is received, the message should be applied to all
        # stored subscriptions on the receiving connection.  This will
        # remove the conditional branching in the Client class, and provide
        # a more flexible means of adding additional behaviors, instead of
        # relying on what is sure to become a giant case statement in Client
        # if we must change state on other Frames later.
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stomper-1.0.0 lib/stomper/frames/message.rb