{ "info": { "author": "Peter Bengtsson", "author_email": "mail@peterbe.com", "bugtrack_url": null, "classifiers": [], "description": "django-sockjs-tornado\n=====================\n\nMakes it easy to run a SockJS server in Django through Tornado.\n\nThis package is basically a thin wrapper on top of `sockjs-tornado\n`_ which makes it dead easy\nto write websocket based apps on top of the `sockjs Websocket\nemulation library `_.\n\nWith this wrapper you basically have access to everything else you\nneed from your Django project such as your models and your various\nsettings.\n\nBecause you need to run two processes (one for `runserver` (or `wsgi`)\nand one for `socketserver`) it means that the two really are separate\npython processes so you can't easily do things like registering\nsignals and trigger them in one process and have them fire in another.\n\nGetting started\n---------------\n\nCreate a class somewhere that looks something like this::\n\n from sockjs.tornado import SockJSConnection\n\n class MyConnection(SockJSConnection):\n def on_open(self, request):\n pass\n def on_message(self, message):\n pass\n def on_close(self):\n pass\n\nNext, you need to put the loction of this in a setting in your\n`settings.py` something like this::\n\n SOCKJS_CLASSES = (\n 'myproject.myapp.myfile.MyConnection',\n )\n\n\nNext, to start the server simply run::\n\n python manage.py socketserver [--help]\n\nYou'll still have your regular django server too in a separate terminal::\n\n python manage.py runserver\n\nNow you should be able to write the juicy Javascript using\n`sockjs-client `_. You can\nstart by downloading the `latest minified version from the CDN\n`_.\n\nA simple app might look like this::\n\n sock = new SockJS('http://localhost:9999/echo');\n sock.onmessage = function(e) {\n console.log(e.data);\n };\n sock.onclose = function() {\n console.log('closed :(');\n };\n sock.onopen = function() {\n console.log('opened :>');\n letTheMadnessBegin();\n };\n\n function letTheMadnessBegin() {\n // silly, but you get the idea\n sock.send(JSON.stringify({\n name: $('#name').text(),\n message: $('input').val()\n }));\n }\n\nGetting fancy\n-------------\n\nThere's a shitload more things you can do with this of course. For\nexample, you might want to add some form of authentication. Since the\n`on_open` handler receives a request you can use that to ask for\n`request.get_cookie()` which is left to the reader as an exercise.\n\nThere is a slightly more fancy example included in this package under\nexample which might get you some ideas. It's a fully working chat\napplication that just works.\n\nThis package is built mainly on `Serve Koval\n`_'s amazing work on `sockjs-tornado\n`_ which has lots of more\nexamples and documentation that might help you. For example, it lists\nto a sample HAProxy configuration which you might need once you take\nyour project live since you can't keep exposing port 9999 on a\nproduction system.", "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/peterbe/django-sockjs-tornado/", "keywords": null, "license": "Copyright (C) 2012 Peter Bengtsson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.", "maintainer": null, "maintainer_email": null, "name": "django-sockjs-tornado", "package_url": "https://pypi.org/project/django-sockjs-tornado/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-sockjs-tornado/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/peterbe/django-sockjs-tornado/" }, "release_url": "https://pypi.org/project/django-sockjs-tornado/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "Makes it easy to run a SockJS server in Django through Tornado", "version": "0.0.1" }, "last_serial": 790702, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "e125a657ef8a157b1347c2026b7efca8", "sha256": "c4497191e3e130eaceff8aadcba473e219035192e7ae2320f034219e5c959413" }, "downloads": -1, "filename": "django-sockjs-tornado-0.0.1.tar.gz", "has_sig": false, "md5_digest": "e125a657ef8a157b1347c2026b7efca8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5350, "upload_time": "2012-09-06T13:50:33", "url": "https://files.pythonhosted.org/packages/ea/31/c2a9346df07fe5516fe1a1c4bc325cc88468b4ff1d387fd8fdff2e5a928f/django-sockjs-tornado-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e125a657ef8a157b1347c2026b7efca8", "sha256": "c4497191e3e130eaceff8aadcba473e219035192e7ae2320f034219e5c959413" }, "downloads": -1, "filename": "django-sockjs-tornado-0.0.1.tar.gz", "has_sig": false, "md5_digest": "e125a657ef8a157b1347c2026b7efca8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5350, "upload_time": "2012-09-06T13:50:33", "url": "https://files.pythonhosted.org/packages/ea/31/c2a9346df07fe5516fe1a1c4bc325cc88468b4ff1d387fd8fdff2e5a928f/django-sockjs-tornado-0.0.1.tar.gz" } ] }