Added python-eventlet 0.15.2 for Ubuntu 14.04
[packages/trusty/python-eventlet.git] / eventlet / doc / modules / websocket.rst
1 :mod:`websocket` -- Websocket Server
2 =====================================
3
4 This module provides a simple way to create a `websocket
5 <http://dev.w3.org/html5/websockets/>`_ server.  It works with a few
6 tweaks in the :mod:`~eventlet.wsgi` module that allow websockets to
7 coexist with other WSGI applications.
8
9 To create a websocket server, simply decorate a handler method with
10 :class:`WebSocketWSGI` and use it as a wsgi application::
11
12     from eventlet import wsgi, websocket
13     import eventlet
14     
15     @websocket.WebSocketWSGI
16     def hello_world(ws):
17         ws.send("hello world")
18     
19     wsgi.server(eventlet.listen(('', 8090)), hello_world)
20
21
22 You can find a slightly more elaborate version of this code in the file
23 ``examples/websocket.py``.
24
25 As of version 0.9.13, eventlet.websocket supports SSL websockets; all that's necessary is to use an :ref:`SSL wsgi server <wsgi_ssl>`.
26
27 .. note :: The web socket spec is still under development, and it will be necessary to change the way that this module works in response to spec changes.
28
29
30 .. automodule:: eventlet.websocket
31         :members: