class Capybara::Poltergeist::WebSocketServer

Public Instance Methods

debugging() click to toggle source
# File lib/dontkillmypry.rb, line 42
def debugging
  Pry.pry_in_use
end
receive() click to toggle source

Block until the next message is available from the Web Socket. Raises Errno::EWOULDBLOCK if timeout is reached.

# File lib/dontkillmypry.rb, line 24
def receive
  start = Time.now

  until @messages.any?
    raise Errno::EWOULDBLOCK if not debugging and (Time.now - start) >= timeout
    begin
      IO.select([socket], [], [], select_timeout) or raise Errno::EWOULDBLOCK
    rescue
      raise unless debugging
    end
    data = socket.recv(RECV_SIZE)
    break if data.empty?
    driver.parse(data)
  end

  @messages.shift
end
select_timeout() click to toggle source
# File lib/dontkillmypry.rb, line 46
def select_timeout
  if debugging
    nil
  else
    timeout
  end
end