Skip to content

Commit

Permalink
add subscribe and unsubscribe to sub sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
grantr committed May 22, 2012
1 parent dff9d2b commit bab03fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/celluloid/zmq/sockets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 bab03fc

Please sign in to comment.