Permalink
Browse files

Merge pull request #7 from grantr/subscribe

add subscribe and unsubscribe to sub sockets
  • Loading branch information...
2 parents 2a360ce + bab03fc commit f8f9f3b556c346f77503b22ac5440133ca362156 @tarcieri tarcieri committed Jun 2, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/celluloid/zmq/sockets.rb
@@ -140,6 +140,18 @@ class SubSocket < Socket
def initialize
super :sub
end
+
+ def subscribe(topic)
+ unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::SUBSCRIBE, topic)
+ raise IOError, "couldn't set subscribe: #{::ZMQ::Util.error_string}"
+ end
+ end
+
+ def unsubscribe(topic)
+ unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::UNSUBSCRIBE, topic)
+ raise IOError, "couldn't set unsubscribe: #{::ZMQ::Util.error_string}"
+ end
+ end
end
end
end

0 comments on commit f8f9f3b

Please sign in to comment.