Class | Capybara::Poltergeist::WebSocketServer |
In: |
lib/capybara/poltergeist/web_socket_server.rb
|
Parent: | Object |
This is a ‘custom’ Web Socket server that is designed to be synchronous. What this means is that it sends a message, and then waits for a response. It does not expect to receive a message at any other time than right after it has sent a message. So it is basically operating a request/response cycle (which is not how Web Sockets are usually used, but it‘s what we want here, as we want to send a message to PhantomJS and then wait for it to respond).
RECV_SIZE | = | 1024 | How much to try to read from the socket at once (it‘s kinda arbitrary because we just keep reading until we‘ve received a full frame) | |
BIND_TIMEOUT | = | 5 | How many seconds to try to bind to the port for before failing |
handler | [R] | |
parser | [R] | |
port | [R] | |
server | [R] | |
socket | [R] | |
timeout | [RW] |
Accept a client on the TCP server socket, then receive its initial HTTP request and use that to initialize a Web Socket.
Note that the socket.read(8) assumes we‘re using the hixie-76 parser. This is fine for now as it corresponds to the version of Web Sockets that the version of WebKit in PhantomJS uses, but it might need to change in the future.