lib/celluloid/zmq/sockets.rb in celluloid-zmq-0.16.0 vs lib/celluloid/zmq/sockets.rb in celluloid-zmq-0.16.1

- old
+ new

@@ -91,10 +91,21 @@ buffer end # Multiparts message ? def_delegator :@socket, :more_parts? + + # Reads a multipart message, stores it into the given buffer and returns + # the buffer. + def read_multipart(buffer = []) + ZMQ.wait_readable(@socket) if ZMQ.evented? + + unless ::ZMQ::Util.resultcode_ok? @socket.recv_strings buffer + raise IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" + end + buffer + end end # Writable 0MQ sockets have a send method module WritableSocket # Send a message to the socket @@ -171,9 +182,20 @@ class PubSocket < Socket include WritableSocket def initialize super :pub + end + end + + # XPubSockets are just like PubSockets but reading from them gives you the + # subscription/unsubscription channels as they're joined/left. + class XPubSocket < Socket + include WritableSocket + include ReadableSocket + + def initialize + super :xpub end end # SubSockets are the counterpart of PubSockets (PUB/SUB) class SubSocket < Socket