Name | sockjs JSON |
Version |
0.13.0
JSON |
| download |
home_page | https://github.com/aio-libs/sockjs/ |
Summary | SockJS server implementation for aiohttp. |
upload_time | 2024-06-13 12:38:09 |
maintainer | None |
docs_url | https://pythonhosted.org/sockjs/ |
author | Nikolay Kim |
requires_python | >=3.10.0 |
license | Apache 2 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
SockJS server based on Asyncio (PEP 3156)
=========================================
.. image:: https://travis-ci.com/aio-libs/sockjs.svg?branch=master
:target: https://travis-ci.com/aio-libs/sockjs
`sockjs` is a `SockJS <http://sockjs.org>`_ integration for
`aiohttp <https://github.com/aio-libs/aiohttp/>`_. SockJS interface
is implemented as a `aiohttp` route. Its possible to create any number
of different sockjs routes, ie `/sockjs/*` or
`/mycustom-sockjs/*`. You can provide different session implementation
and management for each sockjs route.
Simple aiohttp web server is required::
[server:main]
use = egg:gunicorn#main
host = 0.0.0.0
port = 8080
worker = aiohttp.worker.GunicornWebWorker
Example of sockjs route::
def main(global_settings, **settings):
app = web.Application()
app.router.add_route('GET', '/', index)
sockjs.add_endpoint(app, prefix='/sockjs', handler=chatSession)
web.run_app(app)
Client side code::
<script src="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js"></script>
<script>
var sock = new SockJS('http://localhost:8080/sockjs');
sock.onopen = function() {
console.log('open');
sock.send('test');
};
sock.onmessage = function(e) {
console.log('message', e.data);
sock.close();
};
sock.onclose = function() {
console.log('close');
};
</script>
Supported transports
--------------------
* websocket `hybi-10
<http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10>`_
* `xhr-streaming
<https://secure.wikimedia.org/wikipedia/en/wiki/XMLHttpRequest#Cross-domain_requests>`_
* `xhr-polling
<https://secure.wikimedia.org/wikipedia/en/wiki/XMLHttpRequest#Cross-domain_requests>`_
* `iframe-xhr-polling
<https://developer.mozilla.org/en/DOM/window.postMessage>`_
* iframe-eventsource (`EventSource
<http://dev.w3.org/html5/eventsource/>`_ used from an `iframe via
postMessage
<https://developer.mozilla.org/en/DOM/window.postMessage>`_)
* iframe-htmlfile (`HtmlFile
<http://cometdaily.com/2007/11/18/ie-activexhtmlfile-transport-part-ii/>`_
used from an *iframe via postMessage*.
* `jsonp-polling <https://secure.wikimedia.org/wikipedia/en/wiki/JSONP>`_
Requirements
------------
- Python 3.10.0
- gunicorn 19.2.0
- aiohttp https://github.com/aio-libs/aiohttp
Examples
--------
You can find several `examples` in the sockjs repository at github.
https://github.com/aio-libs/sockjs/tree/master/examples
License
-------
sockjs is offered under the Apache 2 license.
=======
CHANGES
=======
0.13.0 (2024-06-13)
-------------------
- Added argument ``cors_config`` into function ``add_endpoint()``
to support of CORS settings from ``aiohttp_cors``.
- Added arguments ``heartbeat_delay`` and ``disconnect_delay``
into function ``add_endpoint()``.
- Function ``add_endpoint()`` now returns all registered routes.
- Replaced returning instances of error HTTP responses
on raising its as exceptions.
- Changed name of some routes.
- Heartbeat task moved from ``SessionManager`` into ``Session``.
- Methods ``_acquire`` and ``_release`` of ``Sessions`` renamed into
``acquire`` and ``release``.
- Added processing of ``ConnectionError`` in ``StreamingTransport``.
- Changed arguments of handler function. Now handler function must be defined
like ``async def handler(manager, session, msg):``
- Constants:
- FRAME_OPEN
- FRAME_CLOSE
- FRAME_MESSAGE
- FRAME_MESSAGE_BLOB
- FRAME_HEARTBEAT
replaced by ``Frame`` enums with corresponding values.
- Constants:
- MSG_OPEN
- MSG_MESSAGE
- MSG_CLOSE
- MSG_CLOSED
replaced by ``MsgType`` enums with corresponding values.
- Constants:
- STATE_NEW
- STATE_OPEN
- STATE_CLOSING
- STATE_CLOSED
replaced by ``SessionState`` enums with corresponding values.
0.12.0 (2022-02-08)
-------------------
- **Breaking change:** Removed argument ``timeout`` from ``Session.__init__()``
and ``SessionManager.__init__()``.
- **Breaking change:** Argument ``heartbeat`` of ``SessionManager.__init__()``
renamed into ``heartbeat_delay``.
- **Breaking change:** ``Session.registry`` renamed into ``Session.app``.
- **Breaking change:** Deleted method ``SessionManager.route_url()``.
- **Breaking change:** Dropped support of Python < 3.7
- Fixed processing of heartbeats and a session expiration.
- Fixed ping-pong based heartbeats for web-socket connections.
- Added arguments ``heartbeat_delay`` and ``disconnect_delay`` into
``Session.__init__()``.
- Added argument ``disconnect_delay`` into ``SessionManager.__init__()``.
0.11.0 (2020-10-22)
-------------------
- **Breaking change:** Added into the WebSocketTransport the ability
to process multi messages from client (#383).
- Added into WebSocketTransport ignoring of empty frames received
from client. (#383).
- Added tick after dequeue so heartbeat keeps session live (#265).
- Fix race condition during iteration over sessions (#217).
- Support Python 3.8.
- Fixed examples of using of SockJS server (#264).
0.10.0 (2019-10-20)
-------------------
- Sync with aiohttp 3.6 (#298)
0.9.1 (2018-12-04)
------------------
- Minor code styling cleanups
0.9.0 (2018-10-11)
------------------
- Support Python 3.7. The minimal available Python version is 3.5.3 (#240)
0.8.0 (2018-06-15)
------------------
- Fix heartbeat (#214)
0.7.1 (2018-03-05)
------------------
- Fix compatibility with aiohttp 3.0+ again.
0.7.0 (2018-02-25)
------------------
- Fixed compatibility with aiohttp 3.0+ (#169)
0.6 (2017-04-13)
----------------
- Fixed support for aiohttp 2.0+.
0.5 (2016-09-26)
----------------
- Mark SockJSRoute.handler and SockJSRoute.websocket as coroutines. #25
- Remove a check for "ORIGIN" header #12
- Process FRAME_MESSAGE_BLOB message type #12
0.4 (2016-02-04)
----------------
- Fixed lost event-loop argument in `sockjs.transports.websocket.WebSocketTransport`
- Fixed lost event-loop argument in `sockjs.transports.rawwebsocket.RawWebSocketTransport`
- Fixed RawRequestMessage. Add raw_header argument (aiohttp 0.21+)
- Fixed many warnings
- Fixed `sockjs.route` add_endpoint without name bug
0.3 (2015-08-07)
----------------
- Fixed calls of ``SessionManager.aquire()`` - was removed the unnecessary second argument.
- Fixed the incorrect argument in one call of ``cors_headers()``.
- Fixed many errors. The code is not perfect, but at least it was working as it should.
0.2 (2015-07-07)
----------------
- Fixed packaging
0.1.0 (2015-06-21)
------------------
- Initial release
Raw data
{
"_id": null,
"home_page": "https://github.com/aio-libs/sockjs/",
"name": "sockjs",
"maintainer": null,
"docs_url": "https://pythonhosted.org/sockjs/",
"requires_python": ">=3.10.0",
"maintainer_email": null,
"keywords": null,
"author": "Nikolay Kim",
"author_email": "fafhrd91@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/00/a4/644d5901d51aecb9fff218bbfc2525ef9362d4d03c2fcb8cb322aa0ce77f/sockjs-0.13.0.tar.gz",
"platform": null,
"description": "SockJS server based on Asyncio (PEP 3156)\n=========================================\n\n.. image:: https://travis-ci.com/aio-libs/sockjs.svg?branch=master\n :target: https://travis-ci.com/aio-libs/sockjs\n\n`sockjs` is a `SockJS <http://sockjs.org>`_ integration for\n`aiohttp <https://github.com/aio-libs/aiohttp/>`_. SockJS interface\nis implemented as a `aiohttp` route. Its possible to create any number\nof different sockjs routes, ie `/sockjs/*` or\n`/mycustom-sockjs/*`. You can provide different session implementation\nand management for each sockjs route.\n\nSimple aiohttp web server is required::\n\n [server:main]\n use = egg:gunicorn#main\n host = 0.0.0.0\n port = 8080\n worker = aiohttp.worker.GunicornWebWorker\n\n\nExample of sockjs route::\n\n def main(global_settings, **settings):\n app = web.Application()\n app.router.add_route('GET', '/', index)\n sockjs.add_endpoint(app, prefix='/sockjs', handler=chatSession)\n web.run_app(app)\n\nClient side code::\n\n <script src=\"https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js\"></script>\n <script>\n var sock = new SockJS('http://localhost:8080/sockjs');\n\n sock.onopen = function() {\n console.log('open');\n sock.send('test');\n };\n\n sock.onmessage = function(e) {\n console.log('message', e.data);\n sock.close();\n };\n\n sock.onclose = function() {\n console.log('close');\n };\n </script>\n\nSupported transports\n--------------------\n\n* websocket `hybi-10\n <http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10>`_\n* `xhr-streaming\n <https://secure.wikimedia.org/wikipedia/en/wiki/XMLHttpRequest#Cross-domain_requests>`_\n* `xhr-polling\n <https://secure.wikimedia.org/wikipedia/en/wiki/XMLHttpRequest#Cross-domain_requests>`_\n* `iframe-xhr-polling\n <https://developer.mozilla.org/en/DOM/window.postMessage>`_\n* iframe-eventsource (`EventSource\n <http://dev.w3.org/html5/eventsource/>`_ used from an `iframe via\n postMessage\n <https://developer.mozilla.org/en/DOM/window.postMessage>`_)\n* iframe-htmlfile (`HtmlFile\n <http://cometdaily.com/2007/11/18/ie-activexhtmlfile-transport-part-ii/>`_\n used from an *iframe via postMessage*.\n* `jsonp-polling <https://secure.wikimedia.org/wikipedia/en/wiki/JSONP>`_\n\n\nRequirements\n------------\n\n- Python 3.10.0\n\n- gunicorn 19.2.0\n\n- aiohttp https://github.com/aio-libs/aiohttp\n\n\nExamples\n--------\n\nYou can find several `examples` in the sockjs repository at github.\n\nhttps://github.com/aio-libs/sockjs/tree/master/examples\n\n\nLicense\n-------\n\nsockjs is offered under the Apache 2 license.\n\n=======\nCHANGES\n=======\n\n0.13.0 (2024-06-13)\n-------------------\n\n- Added argument ``cors_config`` into function ``add_endpoint()``\n to support of CORS settings from ``aiohttp_cors``.\n- Added arguments ``heartbeat_delay`` and ``disconnect_delay``\n into function ``add_endpoint()``.\n- Function ``add_endpoint()`` now returns all registered routes.\n- Replaced returning instances of error HTTP responses\n on raising its as exceptions.\n- Changed name of some routes.\n- Heartbeat task moved from ``SessionManager`` into ``Session``.\n- Methods ``_acquire`` and ``_release`` of ``Sessions`` renamed into\n ``acquire`` and ``release``.\n- Added processing of ``ConnectionError`` in ``StreamingTransport``.\n- Changed arguments of handler function. Now handler function must be defined\n like ``async def handler(manager, session, msg):``\n- Constants:\n\n - FRAME_OPEN\n - FRAME_CLOSE\n - FRAME_MESSAGE\n - FRAME_MESSAGE_BLOB\n - FRAME_HEARTBEAT\n\n replaced by ``Frame`` enums with corresponding values.\n- Constants:\n\n - MSG_OPEN\n - MSG_MESSAGE\n - MSG_CLOSE\n - MSG_CLOSED\n\n replaced by ``MsgType`` enums with corresponding values.\n- Constants:\n\n - STATE_NEW\n - STATE_OPEN\n - STATE_CLOSING\n - STATE_CLOSED\n\n replaced by ``SessionState`` enums with corresponding values.\n\n\n0.12.0 (2022-02-08)\n-------------------\n\n- **Breaking change:** Removed argument ``timeout`` from ``Session.__init__()``\n and ``SessionManager.__init__()``.\n- **Breaking change:** Argument ``heartbeat`` of ``SessionManager.__init__()``\n renamed into ``heartbeat_delay``.\n- **Breaking change:** ``Session.registry`` renamed into ``Session.app``.\n- **Breaking change:** Deleted method ``SessionManager.route_url()``.\n- **Breaking change:** Dropped support of Python < 3.7\n- Fixed processing of heartbeats and a session expiration.\n- Fixed ping-pong based heartbeats for web-socket connections.\n- Added arguments ``heartbeat_delay`` and ``disconnect_delay`` into\n ``Session.__init__()``.\n- Added argument ``disconnect_delay`` into ``SessionManager.__init__()``.\n\n0.11.0 (2020-10-22)\n-------------------\n\n- **Breaking change:** Added into the WebSocketTransport the ability\n to process multi messages from client (#383).\n- Added into WebSocketTransport ignoring of empty frames received\n from client. (#383).\n- Added tick after dequeue so heartbeat keeps session live (#265).\n- Fix race condition during iteration over sessions (#217).\n- Support Python 3.8.\n- Fixed examples of using of SockJS server (#264).\n\n0.10.0 (2019-10-20)\n-------------------\n\n- Sync with aiohttp 3.6 (#298)\n\n0.9.1 (2018-12-04)\n------------------\n\n- Minor code styling cleanups\n\n0.9.0 (2018-10-11)\n------------------\n\n- Support Python 3.7. The minimal available Python version is 3.5.3 (#240)\n\n0.8.0 (2018-06-15)\n------------------\n\n- Fix heartbeat (#214)\n\n0.7.1 (2018-03-05)\n------------------\n\n- Fix compatibility with aiohttp 3.0+ again.\n\n0.7.0 (2018-02-25)\n------------------\n\n- Fixed compatibility with aiohttp 3.0+ (#169)\n\n0.6 (2017-04-13)\n----------------\n\n- Fixed support for aiohttp 2.0+.\n\n0.5 (2016-09-26)\n----------------\n\n- Mark SockJSRoute.handler and SockJSRoute.websocket as coroutines. #25\n\n- Remove a check for \"ORIGIN\" header #12\n\n- Process FRAME_MESSAGE_BLOB message type #12\n\n0.4 (2016-02-04)\n----------------\n\n- Fixed lost event-loop argument in `sockjs.transports.websocket.WebSocketTransport`\n- Fixed lost event-loop argument in `sockjs.transports.rawwebsocket.RawWebSocketTransport`\n- Fixed RawRequestMessage. Add raw_header argument (aiohttp 0.21+)\n- Fixed many warnings\n- Fixed `sockjs.route` add_endpoint without name bug\n\n0.3 (2015-08-07)\n----------------\n\n- Fixed calls of ``SessionManager.aquire()`` - was removed the unnecessary second argument.\n- Fixed the incorrect argument in one call of ``cors_headers()``.\n- Fixed many errors. The code is not perfect, but at least it was working as it should.\n\n0.2 (2015-07-07)\n----------------\n\n- Fixed packaging\n\n0.1.0 (2015-06-21)\n------------------\n\n- Initial release\n",
"bugtrack_url": null,
"license": "Apache 2",
"summary": "SockJS server implementation for aiohttp.",
"version": "0.13.0",
"project_urls": {
"Homepage": "https://github.com/aio-libs/sockjs/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "882abec7bb955323f799a0a041495843aae0eb5aeeeb5b98e13c05d8c633c6e9",
"md5": "9689f636f02697a9865a781fbfecc106",
"sha256": "b00ac14e2d95b9f7c3769a475c06745d529e030fdca278a64b2cc9f4ae2c4d0d"
},
"downloads": -1,
"filename": "sockjs-0.13.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9689f636f02697a9865a781fbfecc106",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10.0",
"size": 26340,
"upload_time": "2024-06-13T12:38:08",
"upload_time_iso_8601": "2024-06-13T12:38:08.078843Z",
"url": "https://files.pythonhosted.org/packages/88/2a/bec7bb955323f799a0a041495843aae0eb5aeeeb5b98e13c05d8c633c6e9/sockjs-0.13.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "00a4644d5901d51aecb9fff218bbfc2525ef9362d4d03c2fcb8cb322aa0ce77f",
"md5": "0d35a367e2e82644112d6070d867bf7c",
"sha256": "57e959a23f20a8d55149d1e5db0b3b870726f2b4ad8166d41bdcf411b36cdf76"
},
"downloads": -1,
"filename": "sockjs-0.13.0.tar.gz",
"has_sig": false,
"md5_digest": "0d35a367e2e82644112d6070d867bf7c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10.0",
"size": 33250,
"upload_time": "2024-06-13T12:38:09",
"upload_time_iso_8601": "2024-06-13T12:38:09.741805Z",
"url": "https://files.pythonhosted.org/packages/00/a4/644d5901d51aecb9fff218bbfc2525ef9362d4d03c2fcb8cb322aa0ce77f/sockjs-0.13.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-13 12:38:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aio-libs",
"github_project": "sockjs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "sockjs"
}