Sha256: c2520a17abb7d09fa54de8db333c481eed3253812572bcfad2ec33b941831306
Contents?: true
Size: 1 KB
Versions: 18
Compression:
Stored size: 1 KB
Contents
require 'dripdrop/message' #Check if we're in 1.8.7 unless defined?(RUBY_ENGINE) require 'zmq' ZMQGEM = :rbzmq else require 'ffi-rzmq' ZMQGEM = :ffirzmq end require 'uri' class DripDrop #The Agent class is a simple ZMQ Pub client. It uses DripDrop::Message messages class Agent attr_reader :address, :context, :socket #address should be a string like tcp://127.0.0.1 def initialize(sock_type,address,sock_ctype) @context = ZMQ::Context.new(1) @socket = @context.socket(sock_type) if sock_ctype == :bind @socket.bind(address) else @socket.connect(address) end end #Sends a DripDrop::Message to the socket def send_message(name,body,head={}) message = DripDrop::Message.new(name,:body => body, :head => head).encoded if ZMQGEM == :rbzmq @socket.send name, ZMQ::SNDMORE @socket.send message else @socket.send_string name, ZMQ::SNDMORE @socket.send_string message end end end end
Version data entries
18 entries across 18 versions & 1 rubygems