Sha256: 2271d1153da38fa531967039e54c456b2071dea8e4bb8b0c90f406a066e4f8c6
Contents?: true
Size: 913 Bytes
Versions: 2
Compression:
Stored size: 913 Bytes
Contents
require 'rubygems' require 'dripdrop/node' Thread.abort_on_exception = true #Define our handlers DripDrop::Node.new do route :pub, :zmq_publish, 'tcp://127.0.0.1:2200', :bind route :sub1, :zmq_subscribe, pub.address, :connect, :topic_filter => /[13579]$/ route :sub2, :zmq_subscribe, pub.address, :connect, :topic_filter => /[02468]$/ route :sub3, :zmq_subscribe, pub.address, :connect sub1.on_receive do |message| puts "Receiver 1 #{message.inspect}" end sub2.on_receive do |message| puts "Receiver 2 #{message.inspect}" end sub3.on_receive do |message| puts "Receiver 3 #{message.inspect}" end EM::PeriodicTimer.new(0.5) do puts "Sending!" #Sending a hash as a message implicitly transforms it into a DripDrop::Message pub.send_message(:name => Time.now.to_i.to_s, :body => 'Test Payload') end end.start! #Start the reactor and block until complete
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dripdrop-0.11.0-java | example/pubsub.rb |
dripdrop-0.11.0 | example/pubsub.rb |