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).

Methods

accept   close   connected?   env   new   receive   send   start_server  

Classes and Modules

Class Capybara::Poltergeist::WebSocketServer::FayeHandler

Constants

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

Attributes

handler  [R] 
parser  [R] 
port  [R] 
server  [R] 
socket  [R] 
timeout  [RW] 

Public Class methods

Public Instance methods

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.

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

Send a message and block until there is a response

[Validate]