Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Showing with 43 additions and 4 deletions.
  1. +2 −0 lib/pan-zmq.rb
  2. +10 −0 lib/pan-zmq/broadcast.rb
  3. +1 −1 lib/pan-zmq/socket.rb
  4. +27 −0 lib/pan-zmq/subscribe.rb
  5. +1 −1 pan-zmq.gemspec
  6. +1 −1 spec/poller_spec.rb
  7. +1 −1 spec/pull_spec.rb
View
2 lib/pan-zmq.rb
@@ -8,6 +8,8 @@
require "pan-zmq/push"
require "pan-zmq/reply"
require "pan-zmq/request"
+require "pan-zmq/broadcast"
+require "pan-zmq/subscribe"
require "pan-zmq/poller"
require "pan-zmq/version"
View
10 lib/pan-zmq/broadcast.rb
@@ -0,0 +1,10 @@
+module PanZMQ
+ class Broadcast
+ include PanZMQ::Socket
+
+ def initialize
+ @socket_type = ZMQ::PUB
+ super
+ end
+ end
+end
View
2 lib/pan-zmq/socket.rb
@@ -67,7 +67,7 @@ def send_string(msg)
def recv_string(flags=0)
return false if not @alive
- flags #||= ZMQ::NOBLOCK
+ flags #||= ZMQ::DONTWAIT
msg = ''
@socket.recv_string(msg, flags)
if defined?(@receive_block)
View
27 lib/pan-zmq/subscribe.rb
@@ -0,0 +1,27 @@
+module PanZMQ
+ class Subscribe
+ include PanZMQ::Socket
+
+ def initialize
+ @socket_type = ZMQ::SUB
+ super
+ end
+
+ def listen(topic)
+ @socket.setsockopt(ZMQ::SUBSCRIBE, topic)
+ end
+
+ def on_receive(&block)
+ @receive_block = block
+ end
+
+ def register
+ PanZMQ::Poller.instance.register(self)
+ end
+
+ def unregister
+ PanZMQ::Poller.instance.unregister(self)
+ end
+
+ end
+end
View
2 pan-zmq.gemspec
@@ -16,5 +16,5 @@ Gem::Specification.new do |gem|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
- gem.add_dependency('ffi-rzmq', '~> 0.9.6')
+ gem.add_dependency('ffi-rzmq', '~> 1.0.0')
end
View
2 spec/poller_spec.rb
@@ -66,7 +66,7 @@
# @pull.bind "tcp://127.0.0.1:5235"
# @push.connect "tcp://127.0.0.1:5235"
#
- # @pull.recv_string(ZMQ::NOBLOCK).should == ""
+ # @pull.recv_string(ZMQ::DONTWAIT).should == ""
# @push.send_string("request")
View
2 spec/pull_spec.rb
@@ -50,7 +50,7 @@
@pull.bind "tcp://127.0.0.1:5235"
@push.connect "tcp://127.0.0.1:5235"
- @pull.recv_string(ZMQ::NOBLOCK).should == ""
+ @pull.recv_string(ZMQ::DONTWAIT).should == ""
@push.send_string("request")

No commit comments for this range

Something went wrong with that request. Please try again.