Class: ZooMQ::Socket
- Inherits:
-
ZMachine::Connection
- Object
- ZMachine::Connection
- ZooMQ::Socket
- Defined in:
- lib/zoomq/socket.rb
Constant Summary collapse
- READABLES =
[ ZMQ::SUB, ZMQ::PULL, ZMQ::ROUTER, ZMQ::DEALER, ZMQ::REP, ZMQ::REQ, ZMQ::PAIR ]
- WRITABLES =
[ ZMQ::PUB, ZMQ::PUSH, ZMQ::ROUTER, ZMQ::DEALER, ZMQ::REP, ZMQ::REQ, ZMQ::PAIR ]
Instance Method Summary collapse
-
#initialize(socket, socket_type, server) ⇒ Socket
constructor
A new instance of Socket.
- #notify_readable ⇒ Object
-
#readable? ⇒ Boolean
# once a writable event is successfully received the socket # should be accepting messages again so stop triggering # write events self.notify_writable = false handle_writable end.
- #writable? ⇒ Boolean
Constructor Details
#initialize(socket, socket_type, server) ⇒ Socket
Returns a new instance of Socket.
10 11 12 13 14 |
# File 'lib/zoomq/socket.rb', line 10 def initialize(socket, socket_type, server) @socket, @socket_type, @server = socket, socket_type, server self.notify_readable = true if READABLES.include?(socket_type) #self.notify_writable = true if WRITABLES.include?(socket_type) end |
Instance Method Details
#notify_readable ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/zoomq/socket.rb', line 16 def notify_readable # Not sure if this is actually necessary. I suppose it prevents us # from having to to instantiate a ZMQ::Message unnecessarily. # I'm leaving this in because its in the docs, but it could probably # be taken out. return unless readable? handle_readable end |
#readable? ⇒ Boolean
# once a writable event is successfully received the socket
# should be accepting messages again so stop triggering
# write events
self.notify_writable = false
handle_writable
end
35 36 37 |
# File 'lib/zoomq/socket.rb', line 35 def readable? (@socket.events & ZMQ::Poller::POLLIN) == ZMQ::Poller::POLLIN end |
#writable? ⇒ Boolean
39 40 41 |
# File 'lib/zoomq/socket.rb', line 39 def writable? (@socket.events & ZMQ::Poller::POLLOUT) == ZMQ::Poller::POLLOUT end |