| 1 |
Metadata-Version: 1.1 |
| 2 |
Name: gevent-websocket |
| 3 |
Version: 0.10.1 |
| 4 |
Summary: Websocket handler for the gevent pywsgi server, a Python network library |
| 5 |
Home-page: https://www.gitlab.com/noppo/gevent-websocket |
| 6 |
Author: Jeffrey Gelens |
| 7 |
Author-email: [email protected] |
| 8 |
License: Copyright 2011-2017 Jeffrey Gelens <[email protected]> |
| 9 |
|
| 10 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 |
you may not use this file except in compliance with the License. |
| 12 |
You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
|
| 22 |
Download-URL: https://www.gitlab.com/noppo/gevent-websocket |
| 23 |
Description: ================ |
| 24 |
gevent-websocket |
| 25 |
================ |
| 26 |
|
| 27 |
`gevent-websocket`_ is a WebSocket library for the gevent_ networking library. |
| 28 |
|
| 29 |
Features include: |
| 30 |
|
| 31 |
- Integration on both socket level or using an abstract interface. |
| 32 |
- RPC and PubSub framework using `WAMP`_ (WebSocket Application |
| 33 |
Messaging Protocol). |
| 34 |
- Easily extendible using a simple WebSocket protocol plugin API |
| 35 |
|
| 36 |
|
| 37 |
:: |
| 38 |
|
| 39 |
from geventwebsocket import WebSocketServer, WebSocketApplication, Resource |
| 40 |
|
| 41 |
class EchoApplication(WebSocketApplication): |
| 42 |
def on_open(self): |
| 43 |
print "Connection opened" |
| 44 |
|
| 45 |
def on_message(self, message): |
| 46 |
self.ws.send(message) |
| 47 |
|
| 48 |
def on_close(self, reason): |
| 49 |
print reason |
| 50 |
|
| 51 |
WebSocketServer( |
| 52 |
('', 8000), |
| 53 |
Resource({'/': EchoApplication}) |
| 54 |
).serve_forever() |
| 55 |
|
| 56 |
or a low level implementation:: |
| 57 |
|
| 58 |
from gevent import pywsgi |
| 59 |
from geventwebsocket.handler import WebSocketHandler |
| 60 |
|
| 61 |
def websocket_app(environ, start_response): |
| 62 |
if environ["PATH_INFO"] == '/echo': |
| 63 |
ws = environ["wsgi.websocket"] |
| 64 |
message = ws.receive() |
| 65 |
ws.send(message) |
| 66 |
|
| 67 |
server = pywsgi.WSGIServer(("", 8000), websocket_app, |
| 68 |
handler_class=WebSocketHandler) |
| 69 |
server.serve_forever() |
| 70 |
|
| 71 |
More examples can be found in the ``examples`` directory. Hopefully more |
| 72 |
documentation will be available soon. |
| 73 |
|
| 74 |
Installation |
| 75 |
------------ |
| 76 |
|
| 77 |
The easiest way to install gevent-websocket is directly from PyPi_ using pip or |
| 78 |
setuptools by running the commands below:: |
| 79 |
|
| 80 |
$ pip install gevent-websocket |
| 81 |
|
| 82 |
|
| 83 |
Gunicorn Worker |
| 84 |
^^^^^^^^^^^^^^^ |
| 85 |
|
| 86 |
Using Gunicorn it is even more easy to start a server. Only the |
| 87 |
`websocket_app` from the previous example is required to start the server. |
| 88 |
Start Gunicorn using the following command and worker class to enable WebSocket |
| 89 |
funtionality for the application. |
| 90 |
|
| 91 |
:: |
| 92 |
|
| 93 |
gunicorn -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" wsgi:websocket_app |
| 94 |
|
| 95 |
Performance |
| 96 |
^^^^^^^^^^^ |
| 97 |
|
| 98 |
`gevent-websocket`_ is pretty fast, but can be accelerated further by |
| 99 |
installing `wsaccel <https://github.com/methane/wsaccel>`_ and `ujson` or `simplejson`:: |
| 100 |
|
| 101 |
$ pip install wsaccel ujson |
| 102 |
|
| 103 |
`gevent-websocket`_ automatically detects ``wsaccell`` and uses the Cython |
| 104 |
implementation for UTF8 validation and later also frame masking and |
| 105 |
demasking. |
| 106 |
|
| 107 |
Get in touch |
| 108 |
^^^^^^^^^^^^ |
| 109 |
|
| 110 |
Get in touch on IRC #gevent on Freenode or on the Gevent `mailinglist |
| 111 |
<https://groups.google.com/forum/#!forum/gevent>`_. Issues can be created |
| 112 |
on `Bitbucket <https://bitbucket.org/Jeffrey/gevent-websocket/issues?status=new&status=open>`_. |
| 113 |
|
| 114 |
.. _WAMP: http://www.wamp.ws |
| 115 |
.. _gevent-websocket: http://www.bitbucket.org/Jeffrey/gevent-websocket/ |
| 116 |
.. _gevent: http://www.gevent.org/ |
| 117 |
.. _Jeffrey Gelens: http://www.gelens.org/ |
| 118 |
.. _PyPi: http://pypi.python.org/pypi/gevent-websocket/ |
| 119 |
.. _repository: http://www.bitbucket.org/Jeffrey/gevent-websocket/ |
| 120 |
.. _RFC6455: http://datatracker.ietf.org/doc/rfc6455/?include_text=1 |
| 121 |
|
| 122 |
Platform: UNKNOWN |
| 123 |
Classifier: Environment :: Web Environment |
| 124 |
Classifier: Intended Audience :: Developers |
| 125 |
Classifier: License :: OSI Approved :: Apache Software License |
| 126 |
Classifier: Operating System :: MacOS :: MacOS X |
| 127 |
Classifier: Operating System :: POSIX |
| 128 |
Classifier: Programming Language :: Python |
| 129 |
Classifier: Programming Language :: Python :: 2 |
| 130 |
Classifier: Programming Language :: Python :: 2.7 |
| 131 |
Classifier: Programming Language :: Python :: 3 |
| 132 |
Classifier: Programming Language :: Python :: 3.5 |
| 133 |
Classifier: Topic :: Internet |
| 134 |
Classifier: Topic :: Software Development :: Libraries :: Python Modules |