Sha256: d1ade7fdd1a3d48f903fe8294fda0b3a8098ebb2483cf9edcf1b96c4d8bc0415

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

module Celluloid
  module ZMQ
    class Socket
      # Writable 0MQ sockets have a send method
      module Writable
        extend Forwardable
        def_delegator ZMQ, :result_ok?
        # Send a message to the socket
        def write(*messages)
          unless result_ok? @socket.send_strings(messages.flatten)
            raise IOError, "error sending 0MQ message: #{::ZMQ::Util.error_string}"
          end

          messages
        end
        alias_method :<<, :write
        alias_method :send, :write # deprecated

        def write_to(address, message)
          error = [IOError, "Failure sending part of message."]
          raise *error unless result_ok? @socket.send_string("#{address}", ::ZMQ::SNDMORE)
          raise *error unless result_ok? @socket.send_string("", ::ZMQ::SNDMORE)
          raise *error unless result_ok? @socket.send_string(message)
          message
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
celluloid-zmq-0.17.0 lib/celluloid/zmq/socket/writable.rb