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:
parent
73ac614f14
commit
4f7a22728c
1 changed files with 5 additions and 4 deletions
|
@ -104,11 +104,12 @@ module Capybara::Poltergeist
|
||||||
end
|
end
|
||||||
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
|
def receive
|
||||||
until handler.message?
|
until handler.message?
|
||||||
IO.select([socket], [], [], timeout)
|
IO.select([socket], [], [], timeout) or raise Errno::EWOULDBLOCK
|
||||||
data = socket.recv_nonblock(RECV_SIZE)
|
data = socket.recv(RECV_SIZE)
|
||||||
break if data.empty?
|
break if data.empty?
|
||||||
handler.parse(data)
|
handler.parse(data)
|
||||||
end
|
end
|
||||||
|
@ -121,7 +122,7 @@ module Capybara::Poltergeist
|
||||||
accept unless connected?
|
accept unless connected?
|
||||||
socket.write handler.encode(message)
|
socket.write handler.encode(message)
|
||||||
receive
|
receive
|
||||||
rescue Errno::EAGAIN, Errno::EWOULDBLOCK
|
rescue Errno::EWOULDBLOCK
|
||||||
raise TimeoutError.new(message)
|
raise TimeoutError.new(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue