Skip to content
This repository
Browse code

Merge pull request #7 from grantr/subscribe

add subscribe and unsubscribe to sub sockets
  • Loading branch information...
commit f8f9f3b556c346f77503b22ac5440133ca362156 2 parents 2a360ce + bab03fc
Tony Arcieri authored June 02, 2012

Showing 1 changed file with 12 additions and 0 deletions. Show diff stats Hide diff stats

  1. 12  lib/celluloid/zmq/sockets.rb
12  lib/celluloid/zmq/sockets.rb
@@ -140,6 +140,18 @@ class SubSocket < Socket
140 140
       def initialize
141 141
         super :sub
142 142
       end
  143
+
  144
+      def subscribe(topic)
  145
+        unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::SUBSCRIBE, topic)
  146
+          raise IOError, "couldn't set subscribe: #{::ZMQ::Util.error_string}"
  147
+        end
  148
+      end
  149
+
  150
+      def unsubscribe(topic)
  151
+        unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::UNSUBSCRIBE, topic)
  152
+          raise IOError, "couldn't set unsubscribe: #{::ZMQ::Util.error_string}"
  153
+        end
  154
+      end
143 155
     end
144 156
   end
145 157
 end

0 notes on commit f8f9f3b

Please sign in to comment.
Something went wrong with that request. Please try again.