README.rdoc in faye-websocket-0.3.0 vs README.rdoc in faye-websocket-0.4.0

- old
+ new

@@ -1,7 +1,10 @@ = Faye::WebSocket +* Travis CI build: {<img src="https://secure.travis-ci.org/faye/faye-websocket-ruby.png" />}[http://travis-ci.org/faye/faye-websocket-ruby] +* Autobahn tests: {server}[http://faye.jcoglan.com/autobahn/servers/], {client}[http://faye.jcoglan.com/autobahn/clients/] + This is a robust, general-purpose WebSocket implementation extracted from the {Faye}[http://faye.jcoglan.com] project. It provides classes for easily building WebSocket servers and clients in Ruby. It does not provide a server itself, but rather makes it easy to handle WebSocket connections within an existing {Rack}[http://rack.rubyforge.org/] application. It does not provide any @@ -70,11 +73,31 @@ # config.ru require './app' Faye::WebSocket.load_adapter('thin') run App +Note that under certain circumstances (notably a draft-76 client connecting +through an HTTP proxy), the WebSocket handshake will not be complete after you +call `Faye::WebSocket.new` because the server will not have received the entire +handshake from the client yet. In this case, calls to `ws.send` will buffer the +message in memory until the handshake is complete, at which point any buffered +messages will be sent to the client. +If you need to detect when the WebSocket handshake is complete, you can use the +`onopen` event. + +If the connection's protocol version supports it, you can call <tt>ws.ping()</tt> +to send a ping message and wait for the client's response. This method takes a +message string, and an optional callback that fires when a matching pong message +is received. It returns +true+ iff a ping message was sent. If the client does +not support ping/pong, this method sends no data and returns +false+. + + ws.ping 'Mic check, one, two' do + # fires when pong is received + end + + == Using the WebSocket client The client supports both the plain-text +ws+ protocol and the encrypted +wss+ protocol, and has exactly the same interface as a socket you would use in a web browser. On the wire it identifies itself as hybi-13. @@ -203,9 +226,13 @@ For example, this creates a connection that pings every 15 seconds and is retryable every 10 seconds if the connection is broken: es = Faye::EventSource.new(es, :ping => 15, :retry => 10) + +You can send a ping message at any time by calling <tt>es.ping()</tt>. Unlike +WebSocket the client does not send a response to this; it is merely to send some +data over the wire to keep the connection alive. == Running your socket application To use this library you must be using an EventMachine-based server; currently