{ "info": { "author": "Sachin Shinde", "author_email": "sachinshinde7676@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# socketcluster-client-python\nRefer examples for more details :\n \nOverview\n--------\nThis client provides following functionality\n\n- Easy to setup and use\n- Can be used for extensive unit-testing of all server side functions\n- Support for emitting and listening to remote events\n- Automatic reconnection\n- Pub/sub\n- Authentication (JWT)\n- Support for python2.x.x / python3.x.x\n\nTo install use\n```python\n sudo pip install socketclusterclient\n```\n\nDescription\n-----------\nCreate instance of `Socket` class by passing url of socketcluster-server end-point \n\n```python\n //Create a socket instance\n socket = Socketcluster.socket(\"ws://localhost:8000/socketcluster/\") \n \n```\n**Important Note** : Default url to socketcluster end-point is always *ws://somedomainname.com/socketcluster/*.\n\n#### Registering basic listeners\n \nDifferent functions are given as an argument to register listeners\n\n```python\n from socketclusterclient import Socketcluster\n import logging\n \n logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)\n \n \n def onconnect(socket):\n logging.info(\"on connect got called\")\n \n \n def ondisconnect(socket):\n logging.info(\"on disconnect got called\")\n \n \n def onConnectError(socket, error):\n logging.info(\"On connect error got called\")\n \n \n def onSetAuthentication(socket, token):\n logging.info(\"Token received \" + token)\n socket.setAuthtoken(token)\n \n \n def onAuthentication(socket, isauthenticated):\n logging.info(\"Authenticated is \" + str(isauthenticated))\n \n \n if __name__ == \"__main__\":\n socket = Socketcluster.socket(\"ws://localhost:8000/socketcluster/\")\n socket.setBasicListener(onconnect, ondisconnect, onConnectError)\n socket.setAuthenticationListener(onSetAuthentication, onAuthentication)\n socket.connect()\n```\n\n#### Connecting to server\n\n- For connecting to server:\n\n```python\n //This will send websocket handshake request to socketcluster-server\n socket.connect();\n```\n\n\n- By default reconnection to server is disabled (since latest release) , to enable it and configure delay for connection\n\n```python\n //This will set automatic-reconnection to server with delay of 2 seconds and repeating it for infinitely\n socket.setdelay(2)\n socket.setreconnection(True)\n socket.connect();\n```\n\n- By default logging of messages in disabled (since latest release), to enable it\n\n```python\n socket.enablelogger(True)\n```\n\nEmitting and listening to events\n--------------------------------\n#### Event emitter\n\n- eventname is name of event and message can be String, boolean, int or JSON-object\n\n```python\n\n socket.emit(eventname,message);\n \n # socket.emit(\"chat\", \"Hi\")\n```\n\n- To send event with acknowledgement\n\n```python\n\n socket.emitack(\"chat\", \"Hi\", ack) \n \n def ack(eventname, error, object):\n print \"Got ack data \" + object + \" and error \" + error + \" and eventname is \" + eventname\n```\n\n#### Event Listener\n\n- For listening to events :\n\nThe object received can be String, Boolean, Long or JSONObject.\n\n```python\n # Receiver code without sending acknowledgement back\n socket.on(\"ping\", message)\n \n def message(eventname, object):\n print \"Got data \" + object + \" from eventname \" + eventname\n```\n\n- To send acknowledgement back to server\n\n```python\n # Receiver code with ack\n socket.onack(\"ping\", messsageack)\n \n def messsageack(eventname, object, ackmessage):\n print \"Got data \" + object + \" from eventname \" + eventname\n ackmessage(\"this is error\", \"this is data\")\n \n```\n\nImplementing Pub-Sub via channels\n---------------------------------\n\n#### Creating channel\n\n- For creating and subscribing to channels:\n\n```python\n \n # without acknowledgement\n socket.subscribe('yell')\n \n #with acknowledgement\n socket.subscribeack('yell', suback)\n \n def suback(channel, error, object):\n if error is '':\n print \"Subscribed successfully to channel \" + channel\n```\n\n- For getting list of created channels :\n \n```python\n channels = socket.getsubscribedchannels()\n\n``` \n\n\n\n\n\n#### Publishing event on channel\n\n- For publishing event :\n\n```python\n\n # without acknowledgement\n socket.publish('yell', 'Hi dudies')\n \n #with acknowledgement\n socket.publishack('yell', 'Hi dudies', puback)\n \n def puback(channel, error, object):\n if error is '':\n print \"Publish sent successfully to channel \" + channel\n``` \n \n#### Listening to channel\n\n- For listening to channel event :\n\n```python\n \n socket.onchannel('yell', channelmessage)\n \n def channelmessage(key, object):\n print \"Got data \" + object + \" from key \" + key\n \n``` \n \n#### Un-subscribing to channel\n\n```python\n # without acknowledgement\n socket.unsubscribe('yell')\n \n # with acknowledgement\n socket.unsubscribeack('yell', unsuback) \n \n def unsuback(channel, error, object):\n if error is '':\n print \"Unsubscribed to channel \" + channel \n```\n \n#### Disable SSL Certificate Verification\n\n```python\n socket = Socketcluster.socket(\"wss://localhost:8000/socketcluster/\")\n socket.connect(sslopt={\"cert_reqs\": ssl.CERT_NONE})\n```\n\n#### HTTP proxy\n\nSupport websocket access via http proxy. The proxy server must allow \"CONNECT\" method to websocket port. Default squid setting is \"ALLOWED TO CONNECT ONLY HTTPS PORT\".\n\n```python\n socket = Socketcluster.socket(\"wss://localhost:8000/socketcluster/\")\n socket.connect(http_proxy_host=\"proxy_host_name\", http_proxy_port=3128)\n```\n\n- To have custom settings over internal logger, you can get logger instance and apply necessary settings over it.\n```python\n sclogger = socket.getlogger()\n```\nPlease follow logging tutorial over here : https://docs.python.org/3/howto/logging-cookbook.html", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/sacOO7/socketcluster-client-python/tarball/v1.3.4", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sacOO7/socketcluster-client-python", "keywords": "websocket", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "socketclusterclient", "package_url": "https://pypi.org/project/socketclusterclient/", "platform": "", "project_url": "https://pypi.org/project/socketclusterclient/", "project_urls": { "Download": "https://github.com/sacOO7/socketcluster-client-python/tarball/v1.3.4", "Homepage": "https://github.com/sacOO7/socketcluster-client-python" }, "release_url": "https://pypi.org/project/socketclusterclient/1.3.4/", "requires_dist": null, "requires_python": "", "summary": "Client library for socketcluster framework in nodejs", "version": "1.3.4" }, "last_serial": 4308848, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "400ebbe6b4a85f4e634d2d27dbdc159c", "sha256": "890bdb134c5d5f1940b759df5004534f86c923b025a67d210202948f25933dcf" }, "downloads": -1, "filename": "socketclusterclient-0.1.tar.gz", "has_sig": false, "md5_digest": "400ebbe6b4a85f4e634d2d27dbdc159c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2838, "upload_time": "2016-11-24T14:43:05", "url": "https://files.pythonhosted.org/packages/13/c7/21a06e16cce280d4bf39b59879fa456f8641fb907709454e6e40334fa1e2/socketclusterclient-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "f847dd515b33f4011165a4dfa2003f48", "sha256": "d8bc0e203716d7001fb424934b34e60b1e780bea476607d7a172badfc3148b03" }, "downloads": -1, "filename": "socketclusterclient-0.2.tar.gz", "has_sig": false, "md5_digest": "f847dd515b33f4011165a4dfa2003f48", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3139, "upload_time": "2016-11-26T18:05:45", "url": "https://files.pythonhosted.org/packages/e9/10/cd0dc7222e7ac2b0d6aeaeec36c5f6395cb4fd95eb6216056d307d5100f3/socketclusterclient-0.2.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "f25ab0063c3c082fc0c0d39f56cd328d", "sha256": "75da7f23792b331aa434c2e38bad49d713302e4ed77f2ca0e6bcb89fc522a7f2" }, "downloads": -1, "filename": "socketclusterclient-1.0.tar.gz", "has_sig": false, "md5_digest": "f25ab0063c3c082fc0c0d39f56cd328d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3195, "upload_time": "2016-12-02T13:15:10", "url": "https://files.pythonhosted.org/packages/1c/8a/fd38899e2977c010de1b4de2eb72b536036a11665388a9b53c92a364a01b/socketclusterclient-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "ec5a5c138e3d8217d9015a5087cb940b", "sha256": "b197ea74fc261b3597b75510439609b63b55d865af05df14cedeaeef762eb9cb" }, "downloads": -1, "filename": "socketclusterclient-1.1.tar.gz", "has_sig": false, "md5_digest": "ec5a5c138e3d8217d9015a5087cb940b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3226, "upload_time": "2016-12-04T06:47:05", "url": "https://files.pythonhosted.org/packages/65/e1/acc46c86faaccf3d2c529ba83554562755caf6d16f5e5e0e0394cc7f1069/socketclusterclient-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "ed9fc5566951bb50a47a0de281529004", "sha256": "e900dde716757413916d452d4e9e57e2686113274e4bb68fc0e6a5244261efa5" }, "downloads": -1, "filename": "socketclusterclient-1.2.tar.gz", "has_sig": false, "md5_digest": "ed9fc5566951bb50a47a0de281529004", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3270, "upload_time": "2016-12-05T08:09:58", "url": "https://files.pythonhosted.org/packages/de/fb/869447b4dc8a798ece0b8a1c8c001f89cf5c30b3eac79cd668e984fc9814/socketclusterclient-1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "0c5f2bd48ff5165bf3ee15285b441bfb", "sha256": "711b9b9d576003d17bc6b263b7929d3cb3e4462432964ab233e7d2bf00c1a288" }, "downloads": -1, "filename": "socketclusterclient-1.2.1.tar.gz", "has_sig": false, "md5_digest": "0c5f2bd48ff5165bf3ee15285b441bfb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3338, "upload_time": "2017-01-03T19:09:20", "url": "https://files.pythonhosted.org/packages/04/9c/73b877ea7500e015d872547634e58e0f0ed688e8b0cd231c92c44574376c/socketclusterclient-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "202e819313f76e49d5539b99214d8896", "sha256": "ec7a76fd0031a9b2fc86d594172525fe825bd6bfa2ac64d52988e2a5366d33a1" }, "downloads": -1, "filename": "socketclusterclient-1.2.2.tar.gz", "has_sig": false, "md5_digest": "202e819313f76e49d5539b99214d8896", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3332, "upload_time": "2017-07-27T06:10:22", "url": "https://files.pythonhosted.org/packages/19/f7/dfe10c0a21656f65c5fb6912bcda52cbda9926a4ffd86249b22da6706486/socketclusterclient-1.2.2.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "462d5545b353b28d1c6394a402a817ce", "sha256": "7c1aa7748603d926f30abcdce703602203faa0c83561a97f92fa60da3f1fbbdd" }, "downloads": -1, "filename": "socketclusterclient-1.3.0.tar.gz", "has_sig": false, "md5_digest": "462d5545b353b28d1c6394a402a817ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3104, "upload_time": "2018-05-19T12:15:21", "url": "https://files.pythonhosted.org/packages/fd/c2/e6b95067c979cc08c3e3e70de726ddb1748627dce62998924524bb36387a/socketclusterclient-1.3.0.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "52f8742dcbb68f70d03b2e53728ec827", "sha256": "f49a107e4ed0ad3883fe3c2198e4f373e229b632ac7a93c72e2e9f25e703e58c" }, "downloads": -1, "filename": "socketclusterclient-1.3.1.tar.gz", "has_sig": false, "md5_digest": "52f8742dcbb68f70d03b2e53728ec827", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4885, "upload_time": "2018-05-19T15:52:05", "url": "https://files.pythonhosted.org/packages/45/df/c1722d2117c07c931c719bc22d107f2a5ffff4404c6d74763c256ae5dc11/socketclusterclient-1.3.1.tar.gz" } ], "1.3.2": [ { "comment_text": "", "digests": { "md5": "44e778807d9c7f6786b7d3d002244bf1", "sha256": "12a177058892e58e861792322c065007a1641f000303c31f9db5d1d0f36682c2" }, "downloads": -1, "filename": "socketclusterclient-1.3.2.tar.gz", "has_sig": false, "md5_digest": "44e778807d9c7f6786b7d3d002244bf1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4930, "upload_time": "2018-05-21T19:04:27", "url": "https://files.pythonhosted.org/packages/8a/f9/815a84141b80c6e431e9bedf4cf9eb591b5e7cbdffa9ecba802b5f793810/socketclusterclient-1.3.2.tar.gz" } ], "1.3.3": [ { "comment_text": "", "digests": { "md5": "5b1bf13e8149ad43774d619dfdbf4134", "sha256": "61f8d4da0e88b1c19e9266626db9d45d42cba336ab2731cdd4e1bb584837bff2" }, "downloads": -1, "filename": "socketclusterclient-1.3.3.tar.gz", "has_sig": false, "md5_digest": "5b1bf13e8149ad43774d619dfdbf4134", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5077, "upload_time": "2018-07-17T14:10:20", "url": "https://files.pythonhosted.org/packages/91/2d/770766ea70233cce44af18ae80ec6030ff2428c5fb640686a23ca4ac99d2/socketclusterclient-1.3.3.tar.gz" } ], "1.3.4": [ { "comment_text": "", "digests": { "md5": "86114e7ebbb95dac9cbb6250a10c1f25", "sha256": "7afcc2e909907a053f708fe1ee5b7226d97d59066b5995d13e55b13982aa2c56" }, "downloads": -1, "filename": "socketclusterclient-1.3.4.tar.gz", "has_sig": false, "md5_digest": "86114e7ebbb95dac9cbb6250a10c1f25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5084, "upload_time": "2018-09-25T15:09:28", "url": "https://files.pythonhosted.org/packages/6d/9a/c91f50544c2f3b0e44b4b818a07fd42a13d62595b0add33d1665d2fcfdbf/socketclusterclient-1.3.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "86114e7ebbb95dac9cbb6250a10c1f25", "sha256": "7afcc2e909907a053f708fe1ee5b7226d97d59066b5995d13e55b13982aa2c56" }, "downloads": -1, "filename": "socketclusterclient-1.3.4.tar.gz", "has_sig": false, "md5_digest": "86114e7ebbb95dac9cbb6250a10c1f25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5084, "upload_time": "2018-09-25T15:09:28", "url": "https://files.pythonhosted.org/packages/6d/9a/c91f50544c2f3b0e44b4b818a07fd42a13d62595b0add33d1665d2fcfdbf/socketclusterclient-1.3.4.tar.gz" } ] }