Code import
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
python-socketio
|
||||
===============
|
||||
|
||||
.. image:: https://travis-ci.org/miguelgrinberg/python-socketio.svg?branch=master
|
||||
:target: https://travis-ci.org/miguelgrinberg/python-socketio
|
||||
|
||||
Python implementation of the `Socket.IO <https://github.com/Automattic/socket.io>`_
|
||||
realtime server.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Fully compatible with the
|
||||
`Javascript <https://github.com/Automattic/socket.io-client>`_,
|
||||
`Swift <https://github.com/socketio/socket.io-client-swift>`_,
|
||||
`C++ <https://github.com/socketio/socket.io-client-cpp>`_ and
|
||||
`Java <https://github.com/socketio/socket.io-client-java>`_ official
|
||||
Socket.IO clients, plus any third party clients that comply with the
|
||||
Socket.IO specification.
|
||||
- Compatible with Python 2.7 and Python 3.3+.
|
||||
- Supports large number of clients even on modest hardware when used with an
|
||||
asynchronous server based on `asyncio <https://docs.python.org/3/library/asyncio.html>`_
|
||||
(`sanic <http://sanic.readthedocs.io/>`_ and `aiohttp <http://aiohttp.readthedocs.io/>`_),
|
||||
`eventlet <http://eventlet.net/>`_ or `gevent <http://gevent.org/>`_. For
|
||||
development and testing, any WSGI complaint multi-threaded server can also be
|
||||
used.
|
||||
- Includes a WSGI middleware that integrates Socket.IO traffic with standard
|
||||
WSGI applications.
|
||||
- Broadcasting of messages to all connected clients, or to subsets of them
|
||||
assigned to "rooms".
|
||||
- Optional support for multiple servers, connected through a messaging queue
|
||||
such as Redis or RabbitMQ.
|
||||
- Send messages to clients from external processes, such as Celery workers or
|
||||
auxiliary scripts.
|
||||
- Event-based architecture implemented with decorators that hides the details
|
||||
of the protocol.
|
||||
- Support for HTTP long-polling and WebSocket transports.
|
||||
- Support for XHR2 and XHR browsers.
|
||||
- Support for text and binary messages.
|
||||
- Support for gzip and deflate HTTP compression.
|
||||
- Configurable CORS responses, to avoid cross-origin problems with browsers.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The following example application uses the `aiohttp <http://aiohttp.readthedocs.io/>`_
|
||||
framework for asyncio:
|
||||
|
||||
.. code:: python
|
||||
|
||||
from aiohttp import web
|
||||
import socketio
|
||||
|
||||
sio = socketio.AsyncServer()
|
||||
app = web.Application()
|
||||
sio.attach(app)
|
||||
|
||||
async def index(request):
|
||||
"""Serve the client-side application."""
|
||||
with open('index.html') as f:
|
||||
return web.Response(text=f.read(), content_type='text/html')
|
||||
|
||||
@sio.on('connect', namespace='/chat')
|
||||
def connect(sid, environ):
|
||||
print("connect ", sid)
|
||||
|
||||
@sio.on('chat message', namespace='/chat')
|
||||
async def message(sid, data):
|
||||
print("message ", data)
|
||||
await sio.emit('reply', room=sid)
|
||||
|
||||
@sio.on('disconnect', namespace='/chat')
|
||||
def disconnect(sid):
|
||||
print('disconnect ', sid)
|
||||
|
||||
app.router.add_static('/static', 'static')
|
||||
app.router.add_get('/', index)
|
||||
|
||||
if __name__ == '__main__':
|
||||
web.run_app(app)
|
||||
|
||||
And below is a similar example, using Flask to serve the client application.
|
||||
This example is compatible with Python 2.7 and Python 3.3+:
|
||||
|
||||
.. code:: python
|
||||
|
||||
import socketio
|
||||
import eventlet
|
||||
import eventlet.wsgi
|
||||
from flask import Flask, render_template
|
||||
|
||||
sio = socketio.Server()
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
"""Serve the client-side application."""
|
||||
return render_template('index.html')
|
||||
|
||||
@sio.on('connect', namespace='/chat')
|
||||
def connect(sid, environ):
|
||||
print("connect ", sid)
|
||||
|
||||
@sio.on('chat message', namespace='/chat')
|
||||
def message(sid, data):
|
||||
print("message ", data)
|
||||
sio.emit('reply', room=sid)
|
||||
|
||||
@sio.on('disconnect', namespace='/chat')
|
||||
def disconnect(sid):
|
||||
print('disconnect ', sid)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# wrap Flask application with engineio's middleware
|
||||
app = socketio.Middleware(sio, app)
|
||||
|
||||
# deploy as an eventlet WSGI server
|
||||
eventlet.wsgi.server(eventlet.listen(('', 8000)), app)
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
- `Documentation`_
|
||||
- `PyPI`_
|
||||
|
||||
.. _Documentation: http://pythonhosted.org/python-socketio
|
||||
.. _PyPI: https://pypi.python.org/pypi/python-socketio
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,150 @@
|
||||
Metadata-Version: 2.0
|
||||
Name: python-socketio
|
||||
Version: 1.7.6
|
||||
Summary: Socket.IO server
|
||||
Home-page: http://github.com/miguelgrinberg/python-socketio/
|
||||
Author: Miguel Grinberg
|
||||
Author-email: miguelgrinberg50@gmail.com
|
||||
License: MIT
|
||||
Platform: any
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Requires-Dist: python-engineio (>=1.2.1)
|
||||
Requires-Dist: six (>=1.9.0)
|
||||
|
||||
python-socketio
|
||||
===============
|
||||
|
||||
.. image:: https://travis-ci.org/miguelgrinberg/python-socketio.svg?branch=master
|
||||
:target: https://travis-ci.org/miguelgrinberg/python-socketio
|
||||
|
||||
Python implementation of the `Socket.IO <https://github.com/Automattic/socket.io>`_
|
||||
realtime server.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Fully compatible with the
|
||||
`Javascript <https://github.com/Automattic/socket.io-client>`_,
|
||||
`Swift <https://github.com/socketio/socket.io-client-swift>`_,
|
||||
`C++ <https://github.com/socketio/socket.io-client-cpp>`_ and
|
||||
`Java <https://github.com/socketio/socket.io-client-java>`_ official
|
||||
Socket.IO clients, plus any third party clients that comply with the
|
||||
Socket.IO specification.
|
||||
- Compatible with Python 2.7 and Python 3.3+.
|
||||
- Supports large number of clients even on modest hardware when used with an
|
||||
asynchronous server based on `asyncio <https://docs.python.org/3/library/asyncio.html>`_
|
||||
(`sanic <http://sanic.readthedocs.io/>`_ and `aiohttp <http://aiohttp.readthedocs.io/>`_),
|
||||
`eventlet <http://eventlet.net/>`_ or `gevent <http://gevent.org/>`_. For
|
||||
development and testing, any WSGI complaint multi-threaded server can also be
|
||||
used.
|
||||
- Includes a WSGI middleware that integrates Socket.IO traffic with standard
|
||||
WSGI applications.
|
||||
- Broadcasting of messages to all connected clients, or to subsets of them
|
||||
assigned to "rooms".
|
||||
- Optional support for multiple servers, connected through a messaging queue
|
||||
such as Redis or RabbitMQ.
|
||||
- Send messages to clients from external processes, such as Celery workers or
|
||||
auxiliary scripts.
|
||||
- Event-based architecture implemented with decorators that hides the details
|
||||
of the protocol.
|
||||
- Support for HTTP long-polling and WebSocket transports.
|
||||
- Support for XHR2 and XHR browsers.
|
||||
- Support for text and binary messages.
|
||||
- Support for gzip and deflate HTTP compression.
|
||||
- Configurable CORS responses, to avoid cross-origin problems with browsers.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The following example application uses the `aiohttp <http://aiohttp.readthedocs.io/>`_
|
||||
framework for asyncio:
|
||||
|
||||
.. code:: python
|
||||
|
||||
from aiohttp import web
|
||||
import socketio
|
||||
|
||||
sio = socketio.AsyncServer()
|
||||
app = web.Application()
|
||||
sio.attach(app)
|
||||
|
||||
async def index(request):
|
||||
"""Serve the client-side application."""
|
||||
with open('index.html') as f:
|
||||
return web.Response(text=f.read(), content_type='text/html')
|
||||
|
||||
@sio.on('connect', namespace='/chat')
|
||||
def connect(sid, environ):
|
||||
print("connect ", sid)
|
||||
|
||||
@sio.on('chat message', namespace='/chat')
|
||||
async def message(sid, data):
|
||||
print("message ", data)
|
||||
await sio.emit('reply', room=sid)
|
||||
|
||||
@sio.on('disconnect', namespace='/chat')
|
||||
def disconnect(sid):
|
||||
print('disconnect ', sid)
|
||||
|
||||
app.router.add_static('/static', 'static')
|
||||
app.router.add_get('/', index)
|
||||
|
||||
if __name__ == '__main__':
|
||||
web.run_app(app)
|
||||
|
||||
And below is a similar example, using Flask to serve the client application.
|
||||
This example is compatible with Python 2.7 and Python 3.3+:
|
||||
|
||||
.. code:: python
|
||||
|
||||
import socketio
|
||||
import eventlet
|
||||
import eventlet.wsgi
|
||||
from flask import Flask, render_template
|
||||
|
||||
sio = socketio.Server()
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
"""Serve the client-side application."""
|
||||
return render_template('index.html')
|
||||
|
||||
@sio.on('connect', namespace='/chat')
|
||||
def connect(sid, environ):
|
||||
print("connect ", sid)
|
||||
|
||||
@sio.on('chat message', namespace='/chat')
|
||||
def message(sid, data):
|
||||
print("message ", data)
|
||||
sio.emit('reply', room=sid)
|
||||
|
||||
@sio.on('disconnect', namespace='/chat')
|
||||
def disconnect(sid):
|
||||
print('disconnect ', sid)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# wrap Flask application with engineio's middleware
|
||||
app = socketio.Middleware(sio, app)
|
||||
|
||||
# deploy as an eventlet WSGI server
|
||||
eventlet.wsgi.server(eventlet.listen(('', 8000)), app)
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
- `Documentation`_
|
||||
- `PyPI`_
|
||||
|
||||
.. _Documentation: http://pythonhosted.org/python-socketio
|
||||
.. _PyPI: https://pypi.python.org/pypi/python-socketio
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
python_socketio-1.7.6.dist-info/DESCRIPTION.rst,sha256=OdQ2VDaGMcz-9REIR7QBQ35ZsJTRG8f5l6D-BouBQeQ,4122
|
||||
python_socketio-1.7.6.dist-info/METADATA,sha256=2JvfeGBB4TbAKOc_zGSrOIiZU8CvqTKUSR6RGN0E08A,4889
|
||||
python_socketio-1.7.6.dist-info/RECORD,,
|
||||
python_socketio-1.7.6.dist-info/WHEEL,sha256=BtVfdXUcEYLcFjOkbIrCFRyXU4qszVPt-E9o3RWkSNw,93
|
||||
python_socketio-1.7.6.dist-info/metadata.json,sha256=rlYn-m1WJ7yXsgUF0t0oZYBMXfgeoxs3uXLuAEGHY_4,979
|
||||
python_socketio-1.7.6.dist-info/top_level.txt,sha256=xWd-HVUanhys_VzQQTRTRZBX8W448ayFytYf1Zffivs,9
|
||||
socketio/__init__.py,sha256=aZVFkmcSR-E0-8JMuXOWYIs7Byjw9ooZGHXn_4SthsI,1016
|
||||
socketio/asyncio_manager.py,sha256=rcUOOS6BU8a0WIElO9b6q6DXEtSfj6q9mjnR3m_J3V4,2035
|
||||
socketio/asyncio_namespace.py,sha256=Z_SqGZkMuJEs9drGs8uopZ4TkDIgZYqcUakDMBisWVs,3814
|
||||
socketio/asyncio_pubsub_manager.py,sha256=EszF9wAOXQvAjF-LkCr6TNvifO1Q_DUb10WKx52bpzc,6470
|
||||
socketio/asyncio_redis_manager.py,sha256=rXH6lVKLcZxwhOcDWO8T_2RkNwcy9obUHAo9hog-hww,2805
|
||||
socketio/asyncio_server.py,sha256=e-RkVxemhShVNfvGsU1LbgEKT0RbeBdbAVjXp622THU,18527
|
||||
socketio/base_manager.py,sha256=Xa1Dkl-_oirXrexr0XEnZ2cJGoO6Vtlhqw1LvyKNB5o,5995
|
||||
socketio/kombu_manager.py,sha256=M8a7RQTJ-uG5hJJahrBH4rX9FeGXeBGvFGARf7lPcFo,3419
|
||||
socketio/middleware.py,sha256=yCWj0D0ipdoaU51Sj89TgwFKx0e0RihTrL-sEiKOiCg,957
|
||||
socketio/namespace.py,sha256=5cLsUXvXyfRj1Kyj5uZ-DAMZQAWQvw3m9FsM7ghTeBQ,4476
|
||||
socketio/packet.py,sha256=M8JpXS8T2_Ijh308BnPMqkTYta59am9PGIPxDkqd5iM,6666
|
||||
socketio/pubsub_manager.py,sha256=t0QI2jZU9Q6GK8kGVP3gCNnch2NJrnfJ949twr5a2C8,6181
|
||||
socketio/redis_manager.py,sha256=p3fpjFUNdsnGfXDxbOUFzNU7D_7t00NU1-jGXieGgTk,2793
|
||||
socketio/server.py,sha256=AGBx8ahWTP4xm5GvBH_WNQvSRMtVdXW8KGd-3X_pnuU,24882
|
||||
socketio/zmq_manager.py,sha256=RwqESwkWZT4_1NdJoz_nhx7WPJgTYqYpSMuXFSQLaTE,3595
|
||||
python_socketio-1.7.6.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
socketio/redis_manager.pyc,,
|
||||
socketio/zmq_manager.pyc,,
|
||||
socketio/namespace.pyc,,
|
||||
socketio/kombu_manager.pyc,,
|
||||
socketio/__init__.pyc,,
|
||||
socketio/server.pyc,,
|
||||
socketio/packet.pyc,,
|
||||
socketio/base_manager.pyc,,
|
||||
socketio/middleware.pyc,,
|
||||
socketio/pubsub_manager.pyc,,
|
||||
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.29.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: cp27-none-any
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"classifiers": ["Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules"], "extensions": {"python.details": {"contacts": [{"email": "miguelgrinberg50@gmail.com", "name": "Miguel Grinberg", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "http://github.com/miguelgrinberg/python-socketio/"}}}, "extras": [], "generator": "bdist_wheel (0.29.0)", "license": "MIT", "metadata_version": "2.0", "name": "python-socketio", "platform": "any", "run_requires": [{"requires": ["python-engineio (>=1.2.1)", "six (>=1.9.0)"]}], "summary": "Socket.IO server", "test_requires": [{"requires": ["mock"]}], "version": "1.7.6"}
|
||||
@@ -0,0 +1 @@
|
||||
socketio
|
||||
Reference in New Issue
Block a user