| 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 |
.. note:: |
| 22 |
|
| 23 |
Please see graceful termination warning in :func:`~eventlet.wsgi.server` |
| 24 |
documentation |
| 25 |
|
| 26 |
|
| 27 |
You can find a slightly more elaborate version of this code in the file |
| 28 |
``examples/websocket.py``. |
| 29 |
|
| 30 |
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>`. |
| 31 |
|
| 32 |
.. 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. |
| 33 |
|
| 34 |
|
| 35 |
.. automodule:: eventlet.websocket |
| 36 |
:members: |