Sha256: d24199b0bb9f50293e93e3d7fd1fb03ad3cbcaa7215d822785333c984cbdf0b8

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module DRbWebSocket
  # A connection instance from DrbWebSocket::Server#accept.
  class ConnectionToClient
    # DRb::DRbServer#main_loop calls `client.uri` method.
    attr_reader :uri

    def initialize(uri, socket, config = {})
      @uri = uri
      @socket = socket
      @config = config
      @msg = DRb::DRbMessage.new(config)
    end

    # Receive a request from the client and return a [object, message, args, block] tuple.
    def recv_request
      @msg.recv_request(@socket)
    end

    #  Send a reply to the client.
    def send_reply(succ, result)
      @msg.send_reply(@socket, succ, result)
    end

    # Close this connection.
    def close
      return unless @socket

      @socket.close
      @socket = nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
drb_protocol_drubyws-0.1.0 lib/drb_web_socket/connection_to_client.rb