Sha256: af03afbdf34f018b5965cb0f9b24a5ae3b27f975aaf8d894c53df97705136754

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

require 'miu'
require 'miu/socket'
require 'miu/packet'

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)
      packet = Packet.new *args
      @socket.send_strings packet.dump
      packet.id
    end

    private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
miu-0.1.0 lib/miu/publisher.rb