README.rdoc in faye-websocket-0.1.2 vs README.rdoc in faye-websocket-0.2.0
- old
+ new
@@ -57,12 +57,12 @@
== 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-08, though it's compatible
-with servers speaking later versions of the protocol, at least up to version 17.
+browser. On the wire it identifies itself as hybi-13, though it's compatible
+with servers speaking later versions of the protocol.
require 'faye/websocket'
require 'eventmachine'
EM.run {
@@ -82,10 +82,30 @@
ws = nil
end
}
+== Subprotocol negotiation
+
+The WebSocket protocol allows peers to select and identify the application
+protocol to use over the connection. On the client side, you can set which
+protocols the client accepts by passing a list of protocol names when you
+construct the socket:
+
+ ws = Faye::WebSocket::Client.new('ws://www.example.com/', ['irc', 'amqp'])
+
+On the server side, you can likewise pass in the list of protocols the server
+supports after the other constructor arguments:
+
+ ws = Faye::WebSocket.new(env, ['irc', 'amqp'])
+
+If the client and server agree on a protocol, both the client- and server-side
+socket objects expose the selected protocol through the <tt>ws.protocol</tt>
+property. If they cannot agree on a protocol to use, the client closes the
+connection.
+
+
== WebSocket API
The WebSocket API consists of several event handlers and a method for sending
messages.
@@ -103,9 +123,11 @@
* <b><tt>send(message)</tt></b> accepts either a +String+ or an +Array+ of
byte-sized integers and sends a text or binary message over the connection to
the other peer.
* <b><tt>close(code, reason)</tt></b> closes the connection, sending the given
status code and reason text, both of which are optional.
+* <b><tt>protocol</tt></b> is a string or +nil+ identifying the subprotocol th
+ socket is using.
== License
(The MIT License)