| Name | txwebsocket JSON |
| Version |
1.1.1
JSON |
| download |
| home_page | |
| Summary | Twisted WebSockets support with Websocket Upgrade |
| upload_time | 2023-08-30 01:54:10 |
| maintainer | |
| docs_url | None |
| author | |
| requires_python | |
| license | MIT/X11 |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
============
txWS Upgrade
============
txWS-Upgrade (pronounced "Twisted WebSockets Upgrade") is a small, short, simple library for
adding WebSockets server support to your favorite Twisted applications.
This is forked from txWS to add upgrade support.
https://github.com/MostAwesomeDude/txWS
Usage
=====
Use ``txwebsocket.txws.WebSocketFactory`` to wrap your factories. That's it! Adding
WebSockets support has never been easier.
>>> from txwebsocket.txws import WebSocketFactory
>>> reactor.listenTCP(8080, WebSocketFactory(factory_to_wrap))
There is no extra trick to txWS. There is no special setup involved.
Do you want secure WebSockets? Use ``listenSSL()`` instead of ``listenTCP()``.
Upgrade Usage
=============
If you want to use the websocket with in an existing site, Update your code as follows.
This is a vanilla Twisted website. ::
from twisted.web import server
from twisted.web.resource import Resource
from twisted.internet import reactor, endpoints
class Simple(Resource):
isLeaf = True
def getChild(self, name, request):
if name == '':
return self
return Resource.getChild(self, name, request)
def render_GET(self, request):
return "Hello, world! I am located at %r." % (request.prepath,)
rootResource = Simple()
site = server.Site(rootResource)
endpoint = endpoints.TCP4ServerEndpoint(reactor, 8080)
endpoint.listen(site)
reactor.run()
Now add the website has support for WebSockets, to include
the ``txwebsocket.txws.WebSocketUpgradeResource`` and ``txwebsocket.txws.WebSocketUpgradeHTTPChannel``. ::
from twisted.web import server
from twisted.web.resource import Resource
from twisted.internet import reactor, endpoints
class Simple(Resource):
isLeaf = True
def getChild(self, name, request):
if name == '':
return self
return Resource.getChild(self, name, request)
def render_GET(self, request):
return "Hello, world! I am located at %r." % (request.prepath,)
rootResource = Simple()
site = server.Site(rootResource)
# 1) Add the imports
# Create the WebSocketFactory
# Create the WebSocketUpgradeResource
# Put the resource into the resource tree
from txwebsocket.txws import WebSocketFactory, WebSocketUpgradeResource
rootResource.putChild(b"websocket",
WebSocketUpgradeResource(WebSocketFactory(factory_to_wrap)))
# 2) Add the imports
# Replace protocol for the website with the Websocket upgradable ones
from txwebsocket.txws import WebSocketUpgradeHTTPChannel
site.protocol = VortexWebsocketHTTPChannel
endpoint = endpoints.TCP4ServerEndpoint(reactor, 8080)
endpoint.listen(site)
reactor.run()
Versions
========
txWS supports the following versions of the WebSockets draft:
* Version 76
* Hixie-76 (Chrome 6, Fx 4, Opera 11, **UNTESTED** Safari 5)
* HyBi-00
* Version 7
* HyBi-07 (Fx 6)
* Version 8
* HyBi-08
* HyBi-10 (Chrome 14, Chrome 15, Fx 7, Fx 8)
* Version 13
* RFC 6455 (Chrome 16)
All listed browser versions have been tested and verified working; any browser
marked "UNTESTED" hasn't been personally tested, but has been reported working
by third parties.
In case you're wondering, the version numbers above are correct; WebSockets
versioning is not sane.
Browser Quirks
==============
This might save you some time when developing your WebSockets-based
application.
* Firefox (all versions): WebSockets do not follow the standard WebSocket
API.
* Opera 11: WebSockets are disabled by default and are very slow to close
connections.
Comparisons
===========
Here's how txWS compares to other Twisted WebSockets libraries.
txWebSockets
------------
txWS, unlike txWebSockets, doesn't reuse any HTTP machinery and doesn't
pretend to be HTTP. Whether this is a good or bad thing depends largely on
whether the WebSockets standard ends up being a valid HTTP subset.
txWS supports newer WS versions 7 and 8, but txWebSockets supports the older
version 75. Both libraries support version 76.
Autobahn
--------
Autobahn provides a client library for WebSockets as well as a server, and
provides a fancy set of messaging protocols on top of the WS layer. Autobahn
also provides support for WS version 10.
However, Autobahn doesn't provide support for WS version 76, and requires
clients to subclass their factories and protocols in order to provide WS
functionality. txWS uses a compositional approach with wrapped protocols,
allowing completely transparent reuse of existing protocols and factories.
Cyclone
-------
Cyclone provides a simple WebSockets handler. This handler can do WS versions
75 and 76. The Cyclone WebSockets handler is very limited, can only wrap other
Cyclone handlers, and doesn't support any of the more modern WebSockets
versions.
License
=======
txWS is (c) 2011 Oregon State University Open Source Lab, (c) 2014 Google
Inc., and is made available under the Apache 2.0 license.
Thanks
======
Thank you to all of the contributors in the community who have chipped in to
help keep txWS alive.
Raw data
{
"_id": null,
"home_page": "",
"name": "txwebsocket",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "Corbin Simpson <simpsoco@osuosl.org>",
"download_url": "https://files.pythonhosted.org/packages/92/cd/4eae81581c79218bdced2b82d27b6b393ef1d9ae7278ee16001db81172a7/txwebsocket-1.1.1.tar.gz",
"platform": null,
"description": "============\ntxWS Upgrade\n============\n\ntxWS-Upgrade (pronounced \"Twisted WebSockets Upgrade\") is a small, short, simple library for\nadding WebSockets server support to your favorite Twisted applications.\n\nThis is forked from txWS to add upgrade support.\nhttps://github.com/MostAwesomeDude/txWS\n\n\nUsage\n=====\n\nUse ``txwebsocket.txws.WebSocketFactory`` to wrap your factories. That's it! Adding\nWebSockets support has never been easier.\n\n >>> from txwebsocket.txws import WebSocketFactory\n >>> reactor.listenTCP(8080, WebSocketFactory(factory_to_wrap))\n\nThere is no extra trick to txWS. There is no special setup involved.\n\nDo you want secure WebSockets? Use ``listenSSL()`` instead of ``listenTCP()``.\n\nUpgrade Usage\n=============\n\nIf you want to use the websocket with in an existing site, Update your code as follows.\n\nThis is a vanilla Twisted website. ::\n\n\n from twisted.web import server\n from twisted.web.resource import Resource\n from twisted.internet import reactor, endpoints\n\n class Simple(Resource):\n isLeaf = True\n def getChild(self, name, request):\n if name == '':\n return self\n return Resource.getChild(self, name, request)\n\n def render_GET(self, request):\n return \"Hello, world! I am located at %r.\" % (request.prepath,)\n\n rootResource = Simple()\n site = server.Site(rootResource)\n\n endpoint = endpoints.TCP4ServerEndpoint(reactor, 8080)\n endpoint.listen(site)\n reactor.run()\n\n\n\nNow add the website has support for WebSockets, to include\n the ``txwebsocket.txws.WebSocketUpgradeResource`` and ``txwebsocket.txws.WebSocketUpgradeHTTPChannel``. ::\n\n from twisted.web import server\n from twisted.web.resource import Resource\n from twisted.internet import reactor, endpoints\n\n class Simple(Resource):\n isLeaf = True\n def getChild(self, name, request):\n if name == '':\n return self\n return Resource.getChild(self, name, request)\n\n def render_GET(self, request):\n return \"Hello, world! I am located at %r.\" % (request.prepath,)\n\n rootResource = Simple()\n site = server.Site(rootResource)\n\n # 1) Add the imports\n # Create the WebSocketFactory\n # Create the WebSocketUpgradeResource\n # Put the resource into the resource tree\n from txwebsocket.txws import WebSocketFactory, WebSocketUpgradeResource\n rootResource.putChild(b\"websocket\",\n WebSocketUpgradeResource(WebSocketFactory(factory_to_wrap)))\n\n\n # 2) Add the imports\n # Replace protocol for the website with the Websocket upgradable ones\n from txwebsocket.txws import WebSocketUpgradeHTTPChannel\n site.protocol = VortexWebsocketHTTPChannel\n\n endpoint = endpoints.TCP4ServerEndpoint(reactor, 8080)\n endpoint.listen(site)\n reactor.run()\n\n\nVersions\n========\n\ntxWS supports the following versions of the WebSockets draft:\n\n * Version 76\n\n * Hixie-76 (Chrome 6, Fx 4, Opera 11, **UNTESTED** Safari 5)\n * HyBi-00\n\n * Version 7\n\n * HyBi-07 (Fx 6)\n\n * Version 8\n\n * HyBi-08\n * HyBi-10 (Chrome 14, Chrome 15, Fx 7, Fx 8)\n\n * Version 13\n\n * RFC 6455 (Chrome 16)\n\nAll listed browser versions have been tested and verified working; any browser\nmarked \"UNTESTED\" hasn't been personally tested, but has been reported working\nby third parties.\n\nIn case you're wondering, the version numbers above are correct; WebSockets\nversioning is not sane.\n\nBrowser Quirks\n==============\n\nThis might save you some time when developing your WebSockets-based\napplication.\n\n * Firefox (all versions): WebSockets do not follow the standard WebSocket\n API.\n * Opera 11: WebSockets are disabled by default and are very slow to close\n connections.\n\nComparisons\n===========\n\nHere's how txWS compares to other Twisted WebSockets libraries.\n\ntxWebSockets\n------------\n\ntxWS, unlike txWebSockets, doesn't reuse any HTTP machinery and doesn't\npretend to be HTTP. Whether this is a good or bad thing depends largely on\nwhether the WebSockets standard ends up being a valid HTTP subset.\n\ntxWS supports newer WS versions 7 and 8, but txWebSockets supports the older\nversion 75. Both libraries support version 76.\n\nAutobahn\n--------\n\nAutobahn provides a client library for WebSockets as well as a server, and\nprovides a fancy set of messaging protocols on top of the WS layer. Autobahn\nalso provides support for WS version 10.\n\nHowever, Autobahn doesn't provide support for WS version 76, and requires\nclients to subclass their factories and protocols in order to provide WS\nfunctionality. txWS uses a compositional approach with wrapped protocols,\nallowing completely transparent reuse of existing protocols and factories.\n\nCyclone\n-------\n\nCyclone provides a simple WebSockets handler. This handler can do WS versions\n75 and 76. The Cyclone WebSockets handler is very limited, can only wrap other\nCyclone handlers, and doesn't support any of the more modern WebSockets\nversions.\n\nLicense\n=======\n\ntxWS is (c) 2011 Oregon State University Open Source Lab, (c) 2014 Google\nInc., and is made available under the Apache 2.0 license.\n\nThanks\n======\n\nThank you to all of the contributors in the community who have chipped in to\nhelp keep txWS alive.\n",
"bugtrack_url": null,
"license": "MIT/X11",
"summary": "Twisted WebSockets support with Websocket Upgrade",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/Synerty/txwebsocket"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "92cd4eae81581c79218bdced2b82d27b6b393ef1d9ae7278ee16001db81172a7",
"md5": "c5ba6a8f9dfd9a68122ae00f111043bd",
"sha256": "fc39153e3b3d425d31e419d5ceb8c90ade222e7f91d4f53ec33c00c04d670d7a"
},
"downloads": -1,
"filename": "txwebsocket-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "c5ba6a8f9dfd9a68122ae00f111043bd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15743,
"upload_time": "2023-08-30T01:54:10",
"upload_time_iso_8601": "2023-08-30T01:54:10.782534Z",
"url": "https://files.pythonhosted.org/packages/92/cd/4eae81581c79218bdced2b82d27b6b393ef1d9ae7278ee16001db81172a7/txwebsocket-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-30 01:54:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Synerty",
"github_project": "txwebsocket",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "txwebsocket"
}