Skip to content
This repository
Browse code

Added changelog and readme section on error handling

  • Loading branch information...
commit 0c94287ababef5f339297472a42d1f33ded7d687 1 parent bbb3135
Martyn Loughran mloughran authored

Showing 2 changed files with 26 additions and 0 deletions. Show diff stats Hide diff stats

  1. +10 0 CHANGELOG.rdoc
  2. +16 0 README.md
10 CHANGELOG.rdoc
Source Rendered
... ... @@ -1,5 +1,15 @@
1 1 = Changelog
2 2
  3 +== 0.3.0
  4 +
  5 +- new features:
  6 + - Support WebSocket drafts 05 & 06
  7 +- changes:
  8 + - Accept request headers in a case insensitive manner
  9 + - Change handling of errors. Previously some application errors were caught
  10 + internally and were invisible unless an onerror callback was supplied. See
  11 + readme for details
  12 +
3 13 == 0.2.1 / 2011-03-01
4 14
5 15 - bugfixes:
16 README.md
Source Rendered
@@ -42,6 +42,22 @@ For example,
42 42 ...
43 43 end
44 44
  45 +## Handling errors
  46 +
  47 +There are two kinds of errors that need to be handled - errors caused by incompatible WebSocket clients sending invalid data and errors in application code. They are handled as follows:
  48 +
  49 +Errors caused by invalid WebSocket data (for example invalid errors in the WebSocket handshake or invalid message frames) raise errors which descend from `EventMachine::WebSocket::WebSocketError`. Such errors are rescued internally and the WebSocket connection will be closed immediately or an error code sent to the browser in accordance to the WebSocket specification. However it is possible to be notified in application code on such errors by including an `onerror` callback.
  50 +
  51 + ws.onerror { |error|
  52 + if e.kind_of?(EM::WebSocket::WebSocketError)
  53 + ...
  54 + end
  55 + }
  56 +
  57 +Application errors are treated differently. If no `onerror` callback has been defined these errors will propagate to the EventMachine reactor, typically causing your program to terminate. If you wish to handle exceptions, simply supply an `onerror callback` and check for exceptions which are not decendant from `EventMachine::WebSocket::WebSocketError`.
  58 +
  59 +It is also possible to log all errors when developing by including the `:debug => true` option when initialising the WebSocket connection.
  60 +
45 61 ## Examples & Projects using em-websocket
46 62
47 63 * [Pusher](http://pusherapp.com) - Realtime client push

0 comments on commit 0c94287

Please sign in to comment.
Something went wrong with that request. Please try again.