1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00

Avoid TCPSocket#recv_nonblock - unsupported by JRuby.

This commit is contained in:
Jon Leighton 2012-02-29 23:01:59 +00:00
parent 73ac614f14
commit 4f7a22728c

View file

@ -104,11 +104,12 @@ module Capybara::Poltergeist
end
end
# Block until the next message is available from the Web Socket
# Block until the next message is available from the Web Socket.
# Raises Errno::EWOULDBLOCK if timeout is reached.
def receive
until handler.message?
IO.select([socket], [], [], timeout)
data = socket.recv_nonblock(RECV_SIZE)
IO.select([socket], [], [], timeout) or raise Errno::EWOULDBLOCK
data = socket.recv(RECV_SIZE)
break if data.empty?
handler.parse(data)
end
@ -121,7 +122,7 @@ module Capybara::Poltergeist
accept unless connected?
socket.write handler.encode(message)
receive
rescue Errno::EAGAIN, Errno::EWOULDBLOCK
rescue Errno::EWOULDBLOCK
raise TimeoutError.new(message)
end