Sha256: 4379938fb8c1c7542b43df57430c786b7994e55174f03dc485c912fe311f109b

Contents?: true

Size: 1.64 KB

Versions: 43

Compression:

Stored size: 1.64 KB

Contents

# Copyright (c) 2012 National ICT Australia Limited (NICTA).
# This software may be used and distributed solely under the terms of the MIT license (License).
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
# By downloading or using this software you accept the terms and the liability disclaimer in the License.



module OmfCommon
  class Comm
    class Local
      class Topic < OmfCommon::Comm::Topic
        @@marshall_messages = true

        # If set to 'true' marshall and immediately unmarshall before handing it on
        # messages
        def self.marshall_messages=(flag)
          @@marshall_messages = (flag == true)
        end

        # def self.address_for(name)
          # "#{name}@local"
        # end

        def to_s
          "Local::Topic<#{id}>"
        end

        def address
          @id
        end

        def on_subscribed(&block)
          return unless block

          OmfCommon.eventloop.after(0) do
            block.arity == 1 ? block.call(self) : block.call
          end
        end

        private

        def _send_message(msg, block = nil)
          super
          debug "(#{id}) Send message #{msg.inspect}"
          if @@marshall_messages
            content_type, payload = msg.marshall(self)
            Message.parse(payload, content_type) do
              OmfCommon.eventloop.after(0) do
                on_incoming_message(msg)
              end
            end
          else
            OmfCommon.eventloop.after(0) do
              on_incoming_message(msg)
            end
          end
        end


      end # class
    end # module
  end # module
end # module

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
omf_common-6.2.3 lib/omf_common/comm/local/local_topic.rb
omf_common-6.2.2 lib/omf_common/comm/local/local_topic.rb
omf_common-6.2.1 lib/omf_common/comm/local/local_topic.rb
omf_common-6.2.0 lib/omf_common/comm/local/local_topic.rb
omf_common-6.2.0.pre.2 lib/omf_common/comm/local/local_topic.rb
omf_common-6.2.0.pre.1 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.14.pre.2 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.14.pre.1 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.12 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.11 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.10 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.9 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.9.pre.4 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.9.pre.3 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.9.pre.2 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.8 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.7 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.6 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.6.pre.2 lib/omf_common/comm/local/local_topic.rb
omf_common-6.1.6.pre.1 lib/omf_common/comm/local/local_topic.rb