Sha256: fc8ff90ef01178b20676d6f944c23c07dda2937bf94a9d4586a06d4af1159ccb

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

module Hara
  class DuplicateResponseError < StandardError
  end

  module ClientInteraction
    attr_reader :socket, :handshake, :client_ip, :client_port

    def socket_setup handshake, socket
      @handshake = handshake
      @socket = socket
      @client_port, @client_ip = Socket.unpack_sockaddr_in(socket.get_peername) #to get ip address of user
    end

    # get client headers
    def headers
      handshake.headers_downcased
    end

    # send msg to client
    def send_msg msg
      message = Hara.encode_msg(type: :push, args: msg)
      socket.send message
    end

    def response_msg msg
      raise NotImplementedError
    end

    # close connection
    def close code = nil, body = nil
      @socket.close code, body
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hara-0.4.0 lib/hara/client_interaction.rb