Sha256: f5566e13ce35b43215781ef851a5f1368ac68eb46d575c97f83f415fc4f5123e

Contents?: true

Size: 538 Bytes

Versions: 2

Compression:

Stored size: 538 Bytes

Contents

require 'miu'
require 'miu/socket'
require 'miu/message'
require 'msgpack'

module Miu
  class Publisher < Socket
    def initialize(options = {})
      options[:port] ||= Miu.default_sub_port
      super socket_type, options

      yield self if block_given?
    end

    # tag, time = nil, body
    def send(*args)
      message = Message.new *args
      @socket.send_strings message.dump
    end

    private

    def socket_type
      if ZMQ::LibZMQ.version3?
        ZMQ::XPUB
      else
        ZMQ::PUB
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miu-0.0.6 lib/miu/publisher.rb
miu-0.0.5 lib/miu/publisher.rb