{ "info": { "author": "Christopher Gamble", "author_email": "chris@chrisgamble.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Twisted", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet" ], "description": "==============\r\nSockJS-Twisted\r\n==============\r\n\r\nA simple library for adding SockJS support to your twisted application.\r\n\r\nStatus\r\n======\r\n\r\nSockJS-Twisted passes all `SockJS-Protocol v0.3.3 `_ tests,\r\nand all `SockJS-Client qunit `_ tests. It has been used in\r\nproduction environments, and should be free of any critical bugs.\r\n\r\nUsage\r\n=====\r\n\r\nUse ``txsockjs.factory.SockJSFactory`` to wrap your factories. That's it!\r\n\r\n.. code-block:: python\r\n \r\n from twisted.internet import reactor\r\n from twisted.internet.protocol import Factory, Protocol\r\n from txsockjs.factory import SockJSFactory\r\n\r\n class HelloProtocol(Protocol):\r\n def connectionMade(self):\r\n self.transport.write('hello')\r\n self.transport.write('how are you?')\r\n\r\n def dataReceived(self, data):\r\n print data\r\n\r\n reactor.listenTCP(8080, SockJSFactory(Factory.forProtocol(HelloProtocol)))\r\n reactor.run()\r\n\r\nThere is nothing else to it, no special setup involved.\r\n\r\nDo you want a secure connection? Use ``listenSSL()`` instead of ``listenTCP()``.\r\n\r\nAdvanced Usage\r\n==============\r\n\r\nFor those who want to host multiple SockJS services off of one port,\r\n``txsockjs.factory.SockJSMultiFactory`` is designed to handle routing for you.\r\n\r\n.. code-block:: python\r\n\r\n from twisted.internet import reactor\r\n from twisted.internet.protocol import Factory, Protocol\r\n from txsockjs.factory import SockJSMultiFactory\r\n from txsockjs.utils import broadcast\r\n\r\n class EchoProtocol(Protocol):\r\n def dataReceived(self, data):\r\n self.transport.write(data)\r\n\r\n class ChatProtocol(Protocol):\r\n def connectionMade(self):\r\n if not hasattr(self.factory, \"transports\"):\r\n self.factory.transports = set()\r\n self.factory.transports.add(self.transport)\r\n\r\n def dataReceived(self, data):\r\n broadcast(data, self.factory.transports)\r\n\r\n def connectionLost(self, reason):\r\n self.factory.transports.remove(self.transport)\r\n\r\n f = SockJSMultiFactory()\r\n f.addFactory(Factory.forProtocol(EchoProtocol), \"echo\")\r\n f.addFactory(Factory.forProtocol(ChatProtocol), \"chat\")\r\n\r\n reactor.listenTCP(8080, f)\r\n reactor.run()\r\n\r\nhttp://localhost:8080/echo and http://localhost:8080/chat will give you access\r\nto your EchoFactory and ChatFactory.\r\n\r\nIntegration With Websites\r\n=========================\r\n\r\nIt is possible to offer static resources, dynamic pages, and SockJS endpoints off of\r\na single port by using ``txsockjs.factory.SockJSResource``.\r\n\r\n.. code-block:: python\r\n\r\n from twisted.internet import reactor\r\n from twisted.internet.protocol import Factory, Protocol\r\n from twisted.web import resource, server\r\n from txsockjs.factory import SockJSResource\r\n\r\n # EchoProtocol and ChatProtocol defined above\r\n\r\n root = resource.Resource()\r\n root.putChild(\"echo\", SockJSResource(Factory.forProtocol(EchoProtocol)))\r\n root.putChild(\"chat\", SockJSResource(Factory.forProtocol(ChatProtocol)))\r\n site = server.Site(root)\r\n\r\n reactor.listenTCP(8080, site)\r\n reactor.run()\r\n\r\nMultiplexing [Experimental]\r\n===========================\r\n\r\nSockJS-Twisted also has built-in support for multiplexing. See the\r\n`Websocket-Multiplex `_ library\r\nfor how to integrate multiplexing client side.\r\n\r\n.. code-block:: python\r\n\r\n from twisted.internet import reactor\r\n from twisted.internet.protocol import Factory, Protocol\r\n from twisted.web import resource, server\r\n from txsockjs.multiplex import SockJSMultiplexResource\r\n\r\n multiplex = SockJSMultiplexResource()\r\n multiplex.addFactory(\"echo\", Factory.forProtocol(EchoProtocol))\r\n multiplex.addFactory(\"chat\", Factory.forProtocol(ChatProtocol))\r\n\r\n root = resource.Resource()\r\n root.putChild(\"multiplex\", multiplex)\r\n site = server.Site(root)\r\n\r\n reactor.listenTCP(8080, site)\r\n reactor.run()\r\n\r\nSingle factory? Multifactory? Resource? Multiplexing? What's the difference?\r\n============================================================================\r\n\r\n+-------------------------+--------------------+----------------------------------+--------------------------+\r\n| Type | Factories per port | Allows mixing native web content | Factories per connection |\r\n+=========================+====================+==================================+==========================+\r\n| SockJSFactory | Single | No | Single |\r\n+-------------------------+--------------------+----------------------------------+--------------------------+\r\n| SockJSMultiFactory | Multiple | No | Single |\r\n+-------------------------+--------------------+----------------------------------+--------------------------+\r\n| SockJSResource | Multiple | Yes | Single |\r\n+-------------------------+--------------------+----------------------------------+--------------------------+\r\n| SockJSMultiplexResource | Multiple | Yes | Multiple |\r\n+-------------------------+--------------------+----------------------------------+--------------------------+\r\n\r\n``SockJSFactory`` is recommended for use in non-web (HTTP) applications to allow\r\nnative web connections. For instance, an IRC server. There can only be one factory\r\nlistening on a port using this method. The SockJS endpoint uses this internally.\r\n\r\n``SockJSMultiFactory`` is recommended for use in non-web (HTTP) applications with\r\nmultiple services. This allows multiple factories to listen on a single port.\r\n\r\n``SockJSResource`` is recommended for use in HTTP based applications, like webservers.\r\n\r\n``SockJSMultiplexResource`` is recommended for pubsub applications, where each connection\r\nneeds to talk to multiple factories. Overriding the subscribe method allows for dynamic\r\nfactory creation if you don't know what is needed server-side ahead of time.\r\n\r\nEndpoints\r\n=========\r\n\r\nFor integration with pre-existing libraries or programs, it is possible use sockjs\r\nas an endpoint in the form ``sockjs:tcp\\:9090\\:interface\\=0.0.0.0:encoding=utf8:websocket=false``.\r\nYou can pass any escaped endpoint to a sockjs endpoint to wrap it with txsockjs, and you can\r\nspecify any option for the SockJSFactory by specifying it as a keyword argument.\r\nFor more information, read the\r\n`twisted documentation on endpoints `_.\r\n\r\n.. code-block:: python\r\n\r\n from twisted.internet import reactor\r\n from twisted.internet.protocol import Factory, Protocol\r\n from twisted.internet.endpoints import serverFromString\r\n # Note that we don't have to import anything from txsockjs\r\n\r\n # HelloProtocol defined above\r\n\r\n endpoint = serverFromString(reactor, \"sockjs:tcp\\:8080\")\r\n endpoint.listen(Factory.forProtocol(HelloProtocol))\r\n reactor.run()\r\n\r\nOptions\r\n=======\r\n\r\nA dictionary of options can be passed into the factory to control SockJS behavior.\r\n\r\n.. code-block:: python\r\n\r\n options = {\r\n 'websocket': True,\r\n 'cookie_needed': False,\r\n 'heartbeat': 25,\r\n 'timeout': 5,\r\n 'streaming_limit': 128 * 1024,\r\n 'encoding': 'cp1252', # Latin1\r\n 'sockjs_url': 'https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.js',\r\n 'proxy_header': None\r\n }\r\n SockJSFactory(factory_to_wrap, options)\r\n SockJSMultiFactory().addFactory(factory_to_wrap, prefix, options)\r\n SockJSResource(factory_to_wrap, options)\r\n SockJSMultiplexResource(options)\r\n\r\nwebsocket :\r\n whether websockets are supported as a protocol. Useful for proxies or load balancers that don't support websockets.\r\n\r\ncookie_needed :\r\n whether the JSESSIONID cookie is set. Results in less performant protocols being used, so don't require them unless your load balancer requires it.\r\n\r\nheartbeat :\r\n how often a heartbeat message is sent to keep the connection open. Do not increase this unless you know what you are doing.\r\n\r\ntimeout :\r\n maximum delay between connections before the underlying protocol is disconnected\r\n\r\nstreaming_limit :\r\n how many bytes can be sent over a streaming protocol before it is cycled. Allows browser-side garbage collection to lower RAM usage.\r\n\r\nencoding :\r\n All messages to and from txsockjs should be valid UTF-8. In the event that a message received by txsockjs is not UTF-8, fall back to this encoding.\r\n\r\nsockjs_url :\r\n The url of the SockJS library to use in iframes. By default this is served over HTTPS and therefore shouldn't need changing.\r\n\r\nproxy_header :\r\n The HTTP header to pull a proxied IP address out of. Leave as None to get the unproxied IP. **Do not change this unless you are behind a proxy you control.**\r\n\r\nLicense\r\n=======\r\n\r\nSockJS-Twisted is (c) 2012 Christopher Gamble and is made available under the BSD license.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/Fugiman/sockjs-twisted", "keywords": null, "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "txsockjs", "package_url": "https://pypi.org/project/txsockjs/", "platform": "OS Independent", "project_url": "https://pypi.org/project/txsockjs/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/Fugiman/sockjs-twisted" }, "release_url": "https://pypi.org/project/txsockjs/1.2.2/", "requires_dist": null, "requires_python": null, "summary": "Twisted SockJS wrapper", "version": "1.2.2" }, "last_serial": 1325028, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "eb0edd2946a577eac569e85aa3ad5a23", "sha256": "8abeeae1697b7d898c4b92fc5f774022d45906377204ea90277934675a403e5f" }, "downloads": -1, "filename": "txsockjs-0.1.zip", "has_sig": false, "md5_digest": "eb0edd2946a577eac569e85aa3ad5a23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31405, "upload_time": "2012-06-30T16:42:24", "url": "https://files.pythonhosted.org/packages/f6/88/9bcf56e8b7ac05edca6f23a042df231140cb12f161f1fa97d5864b8a9fb2/txsockjs-0.1.zip" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7f3eed616382119c7dc079839b60c224", "sha256": "6273bb21fab743bd1af5f0cb3f60b40c7c1370ff52a61edbcbe1acec6a7573fe" }, "downloads": -1, "filename": "txsockjs-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7f3eed616382119c7dc079839b60c224", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13398, "upload_time": "2012-08-08T03:37:44", "url": "https://files.pythonhosted.org/packages/71/c9/d900c69ef658de16374268dbab395454eb3a16d2b02463d248275df6f99b/txsockjs-0.1.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "30058069d474603988a85fe4e2ac3984", "sha256": "b29c60bed32751c4a25fe70889394b788a899d9cd0b49b92cc106100ae0a217d" }, "downloads": -1, "filename": "txsockjs-1.0.0.zip", "has_sig": false, "md5_digest": "30058069d474603988a85fe4e2ac3984", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 37826, "upload_time": "2013-01-26T19:43:25", "url": "https://files.pythonhosted.org/packages/c7/ae/9910746eea5b42ca2cc33d3b25e64658784941a23f07eff443a4faa9e2cd/txsockjs-1.0.0.zip" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "f5dc5c987cdb05f0d3fd48252bebb31c", "sha256": "8c36a862e3ed47a476a2e787d14cf97128542c70c2a603501608bc91f73c307c" }, "downloads": -1, "filename": "txsockjs-1.1.0.zip", "has_sig": false, "md5_digest": "f5dc5c987cdb05f0d3fd48252bebb31c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40486, "upload_time": "2013-03-14T00:17:09", "url": "https://files.pythonhosted.org/packages/ed/a7/f1bfedcd0655795ef318678481aa718ebf4e450403564bc30c3f59c78f3a/txsockjs-1.1.0.zip" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "6a2ff80282a9834932178a591e6fdc54", "sha256": "8578f05b7c8c5481a18e67961d50cec357fa1f4407542b683c048cf29bf33cac" }, "downloads": -1, "filename": "txsockjs-1.1.1.zip", "has_sig": false, "md5_digest": "6a2ff80282a9834932178a591e6fdc54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40492, "upload_time": "2013-06-28T17:16:09", "url": "https://files.pythonhosted.org/packages/d7/6f/fd00cda797d68768834d0bf7f04a8e529491862678afc73137cbab8d33d8/txsockjs-1.1.1.zip" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "8982ba642b01ac329826b0c8f64b3101", "sha256": "6ab1ae0d804ba1da6f182839914c73d3fd2ad7858fc47b1d568236cc36b8fce7" }, "downloads": -1, "filename": "txsockjs-1.2.0.tar.gz", "has_sig": false, "md5_digest": "8982ba642b01ac329826b0c8f64b3101", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27385, "upload_time": "2013-09-19T22:01:09", "url": "https://files.pythonhosted.org/packages/3b/ed/829226b30716b0f90af7c3ca9b93aae22abad7d9b29ca1753345e6ef0589/txsockjs-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "7ce976ae6cee221e3f4ce3e0f3ed1c8c", "sha256": "208d0fedfdea987b2cebc82d47bd389c4128bf127ee8f6acb62813f4b0ac973c" }, "downloads": -1, "filename": "txsockjs-1.2.1.tar.gz", "has_sig": false, "md5_digest": "7ce976ae6cee221e3f4ce3e0f3ed1c8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27385, "upload_time": "2013-09-21T04:42:14", "url": "https://files.pythonhosted.org/packages/2f/5d/e2bb9f7d4e42ada1dfeb211573c75b9d42e2785bef04be5d73789d3c1ee1/txsockjs-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "fcdd3f68021abc6034223b5b36f43128", "sha256": "759f5571e276e70c1ad20919d27cf2e8eef8751594892bd107d6e88dce4a5db9" }, "downloads": -1, "filename": "txsockjs-1.2.2.tar.gz", "has_sig": false, "md5_digest": "fcdd3f68021abc6034223b5b36f43128", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27190, "upload_time": "2014-11-29T21:04:02", "url": "https://files.pythonhosted.org/packages/df/17/6429c99d3bfd7f6bc0f8aacc72a350f1113cdda2079094593edcfc568706/txsockjs-1.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fcdd3f68021abc6034223b5b36f43128", "sha256": "759f5571e276e70c1ad20919d27cf2e8eef8751594892bd107d6e88dce4a5db9" }, "downloads": -1, "filename": "txsockjs-1.2.2.tar.gz", "has_sig": false, "md5_digest": "fcdd3f68021abc6034223b5b36f43128", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27190, "upload_time": "2014-11-29T21:04:02", "url": "https://files.pythonhosted.org/packages/df/17/6429c99d3bfd7f6bc0f8aacc72a350f1113cdda2079094593edcfc568706/txsockjs-1.2.2.tar.gz" } ] }