lib/celluloid/zmq/sockets.rb in celluloid-zmq-0.12.0 vs lib/celluloid/zmq/sockets.rb in celluloid-zmq-0.13.0.pre

- old
+ new

@@ -38,11 +38,11 @@ @socket.close end # Does the 0MQ socket support evented operation? def evented? - actor = Thread.current[:actor] + actor = Thread.current[:celluloid_actor] return unless actor mailbox = actor.mailbox mailbox.is_a?(Celluloid::IO::Mailbox) && mailbox.reactor.is_a?(Celluloid::ZMQ::Reactor) end @@ -51,10 +51,12 @@ alias_method :inspect, :to_s end # Readable 0MQ sockets have a read method module ReadableSocket + extend Forwardable + # always set LINGER on readable sockets def bind(addr) self.linger = @linger super(addr) end @@ -71,10 +73,13 @@ unless ::ZMQ::Util.resultcode_ok? @socket.recv_string buffer raise IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" end buffer end + + # Multiparts message ? + def_delegator :@socket, :more_parts? end # Writable 0MQ sockets have a send method module WritableSocket # Send a message to the socket @@ -104,9 +109,29 @@ include ReadableSocket include WritableSocket def initialize super :rep + end + end + + # DealerSockets are like ReqSockets but more flexible + class DealerSocket < Socket + include ReadableSocket + include WritableSocket + + def initialize + super :dealer + end + end + + # RouterSockets are like RepSockets but more flexible + class RouterSocket < Socket + include ReadableSocket + include WritableSocket + + def initialize + super :router end end # PushSockets are the counterpart of PullSockets (PUSH/PULL) class PushSocket < Socket