# The Socket library uses the IO::Buffered module.
# IO::Buffered needs a new function to check if there is still something to read
# in its buffer. Since WebSocket is compatible with all IO instances, then IO
# needs this function as well, even if it doesn't really makes sense here.
classIO
defempty?:Bool
true
end
end
moduleIO::Buffered
# :nodoc:
defempty?:Bool
@in_buffer_rem.size==0
end
end
classHTTP::WebSocket
# Infinite loop over `run_once`.
# Stops when the socket closes or an error occurs.
defrun
loopdo
ret=run_once
caseret
whenError|Close
break
end
end
end
# `run_once` returns the type of the message which could be a Ping or Pong message, a closing socket, an error (when an exception occurs) or a message that is not yet entirely received.