{ "info": { "author": "Chris McCormick", "author_email": "chris@mccormick.cx", "bugtrack_url": null, "classifiers": [], "description": "PodSixNet - lightweight multiplayer networking library for Python games\n-----------------------------------------------------------------------\n\nPodSixNet is a lightweight network layer designed to make it easy to\nwrite multiplayer games in Python. It uses Python's built in asyncore\nlibrary and rencode.py (included) to asynchronously serialise network\nevents and arbitrary data structures, and deliver them to your high\nlevel classes through simple callback methods.\n\nEach class within your game client which wants to receive network\nevents, subclasses the ConnectionListener class and then implements\n``Network_*`` methods to catch specific user-defined events from the\nserver. You don't have to wait for buffers to fill, or check sockets for\nwaiting data or anything like that, just do ``connection.Pump()`` once\nper game loop and the library will handle everything else for you,\npassing off events to all classes that are listening. Sending data back\nto the server is just as easy, using ``connection.Send(mydata)``.\nLikewise on the server side, events are propagated to ``Network_*``\nmethod callbacks and data is sent back to clients with the\n``client.Send(mydata)`` method.\n\nThe `PodSixNet mailing\nlist `__ is good for getting\nhelp from other users.\n\nFor users of the Construct game making environment for Windows, there is\na tutorial on doing multiplayer networking with PodSixNet,\n`here `__. Thanks\nto Dave Chabo for contributing this tutorial.\n\nHere is `another tutorial by Julian\nMeyer `__.\n\nInstall\n-------\n\n``pip install PodSixNet``\n\nor\n\n``easy_install PodSixNet``\n\nFrom source\n~~~~~~~~~~~\n\nFirst make sure you have `Python `__ 2.4 or greater\ninstalled (python 3 also works).\n\nNext you'll want to get the PodSixNet source.\n\nThe module is found inside a subdirectory called PodSixNet within the\ntop level folder. There's an ``__init__.py`` inside there, so you can\njust copy or symlink the PodSixNet sub-directory into your own project\nand then do ``import PodSixNet``, or else you can run\n``sudo python setup.py install`` to install PodSixNet into your Python\npath. Use ``sudo python setup.py develop`` if you want to stay up to\ndate with the cutting edge and still be able to svn/bzr up every now and\nthen.\n\nBy default PodSixNet uses a binary encoder to transfer data over the\nnetwork, but it can optionally use the `JSON `__\nformat or other formats supported by a serialiser which has 'dumps' and\n'loads' methods. If you want to serialise your data using JSON you can\nchange the first line of Channel.py to 'from simplejson import dumps,\nloads' or use the built-in json library in Python 2.6 or higher. This\nwill allow you to write game clients in languages that can't read the\n'rencode' binary format, such as Javascript.\n\nExamples\n--------\n\nChat example:\n\n- ``python examples/ChatServer.py``\n- and a couple of instances of ``python examples/ChatClient.py``\n\nWhiteboard example:\n\n- ``python examples/WhiteboardServer.py``\n- and a couple of instances of ``python examples/WhiteboardClient.py``\n\nLagTime example (measures round-trip time from the server to the\nclient):\n\n- ``python examples/LagTimeServer.py``\n- and a couple of instances of ``python examples/LagTimeClient.py``\n\nQuick start - Server\n--------------------\n\nYou will need to subclass two classes in order to make your own server.\nEach time a client connects, a new Channel based class will be created,\nso you should subclass Channel to make your own\nserver-representation-of-a-client class like this:\n\n::\n\n from PodSixNet.Channel import Channel\n\n class ClientChannel(Channel):\n\n def Network(self, data):\n print data\n \n def Network_myaction(self, data):\n print \"myaction:\", data\n\nWhenever the client does ``connection.Send(mydata)``, the ``Network()``\nmethod will be called. The method ``Network_myaction()`` will only be\ncalled if your data has a key called 'action' with a value of\n\"myaction\". In other words if it looks something like this:\n\n::\n\n data = {\"action\": \"myaction\", \"blah\": 123, ... }\n\nNext you need to subclass the Server class like this:\n\n::\n\n from PodSixNet.Server import Server\n\n class MyServer(Server):\n \n channelClass = ClientChannel\n \n def Connected(self, channel, addr):\n print 'new connection:', channel\n\nSet ``channelClass`` to the channel class that you created above. The\nmethod ``Connected()`` will be called whenever a new client connects to\nyour server. See the example servers for an idea of what you might do\neach time a client connects. You need to call ``Server.Pump()`` every\nnow and then, probably once per game loop. For example:\n\n::\n\n myserver = MyServer()\n while True:\n myserver.Pump()\n sleep(0.0001)\n\nWhen you want to send data to a specific client/channel, use the Send\nmethod of the Channel class:\n\n::\n\n channel.Send({\"action\": \"hello\", \"message\": \"hello client!\"})\n\nQuick start - Client\n--------------------\n\nTo have a client connect to your new server, you should use the\nConnection module. See ``pydoc Connection`` for more details, but here's\na summary:\n\n``Connection.connection`` is a singleton Channel which connects to the\nserver. You'll only have one of these in your game code, and you'll use\nit to connect to the server and send messages to the server.\n\n::\n\n from PodSixNet.Connection import connection\n\n # connect to the server - optionally pass hostname and port like: (\"mccormick.cx\", 31425)\n connection.Connect()\n\n connection.Send({\"action\": \"myaction\", \"blah\": 123, \"things\": [3, 4, 3, 4, 7]})\n\nYou'll also need to put the following code once somewhere in your game\nloop:\n\n::\n\n connection.Pump()\n\nAny time you have an object in your game which you want to receive\nmessages from the server, subclass ``ConnectionListener``. For example:\n\n::\n\n from PodSixNet.Connection import ConnectionListener\n\n class MyNetworkListener(ConnectionListener):\n\n def Network(self, data):\n print 'network data:', data\n \n def Network_connected(self, data):\n print \"connected to the server\"\n \n def Network_error(self, data):\n print \"error:\", data['error'][1]\n \n def Network_disconnected(self, data):\n print \"disconnected from the server\"\n \n def Network_myaction(data):\n print \"myaction:\", data\n\nJust like in the server case, the network events are received by\n``Network_*`` callback methods, where you should replace '\\*' with the\nvalue in the 'action' key you want to catch. You can implement as many\nor as few of the above as you like. For example, NetworkGUI would\nprobably only want to listen for the ``_connected``, ``_disconnected``,\nand ``_error`` network events. The data for ``_error`` always comes in\nthe form of network exceptions, like (111, 'Connection refused') - these\nare passed straight from the socket layer and are standard socket\nerrors.\n\nAnother class might implement custom methods like\n``Network_myaction()``, which will receive any data that gets sent from\nthe server with an 'action' key that has the name 'myaction'. For\nexample, the server might send a message with the number of players\ncurrently connected like so:\n\n::\n\n channel.Send({\"action\": \"numplayers\", \"players\": 10})\n\nAnd the listener would look like this:\n\n::\n\n from PodSixNet.Connection import ConnectionListener\n\n class MyPlayerListener(ConnectionListener):\n\n def Network_numplayers(data):\n # update gui element displaying the number of currently connected players\n print data['players']\n\nYou can subclass ``ConnectionListener`` as many times as you like in\nyour application, and every class you make which subclasses it will\nreceive the network events via named Network callbacks. You should call\nthe ``Pump()`` method on each object you instantiate once per game loop:\n\n::\n\n gui = MyPlayerListener()\n while 1:\n connection.Pump()\n gui.Pump()\n\nLicense\n-------\n\nCopyright `Chris McCormick `__, 2009-2015.\n\nPodSixNet is licensed under the terms of the LGPL v3.0 or higher. See\nthe file called `COPYING `__ for details.\n\nThis basically means that you can use it in most types of projects\n(commercial or otherwise), but if you make changes to the PodSixNet code\nyou must make the modified code available with the distribution of your\nsoftware. Hopefully you'll tell us about it so we can incorporate your\nchanges. I am not a lawyer, so please read the license carefully to\nunderstand your rights with respect to this code.\n\nWhy not use Twisted instead?\n----------------------------\n\nTwisted is a fantastic library for writing robust network code. I have\nused it in several projects in the past, and it was quite nice to work\nwith. That said, Twisted:\n\n- wants to steal the mainloop\n- is bloated not KISS (it implements many many different protocols)\n- has a weird template launching language when Python should do just\n fine\n- is not written 100% for the specfic use-case of multiplayer games\n\nThese are some of the reasons why I decided to write a library that is\nlightweight, has no dependencies except Python, and is dedicated 100% to\nthe task of multiplayer game networking.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/chr15m/PodSixNet", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "PodSixNet", "package_url": "https://pypi.org/project/PodSixNet/", "platform": "", "project_url": "https://pypi.org/project/PodSixNet/", "project_urls": { "Homepage": "https://github.com/chr15m/PodSixNet" }, "release_url": "https://pypi.org/project/PodSixNet/0.11.0/", "requires_dist": null, "requires_python": "", "summary": "Multiplayer networking library for games", "version": "0.11.0" }, "last_serial": 4299436, "releases": { "0.10.0": [ { "comment_text": "", "digests": { "md5": "f217cd1630b2592e05f0540a12dc6ca4", "sha256": "7055bdd58cf2f405c87f58dcb95bc57830f40573b7afcbe88b02013212dd9518" }, "downloads": -1, "filename": "PodSixNet-0.10.0.tar.gz", "has_sig": false, "md5_digest": "f217cd1630b2592e05f0540a12dc6ca4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12025, "upload_time": "2018-09-12T11:37:53", "url": "https://files.pythonhosted.org/packages/2d/49/21eea4441f11ee8c832ca107e42eaf1d284c3745a86668f4e598c0f3b2ba/PodSixNet-0.10.0.tar.gz" } ], "0.11.0": [ { "comment_text": "", "digests": { "md5": "b5f04752daee1183141026a2e91ba238", "sha256": "5c235a73eddbabe8169ea7b51b115e55ce17d126574bebcbcee37d3d1b414e48" }, "downloads": -1, "filename": "PodSixNet-0.11.0.tar.gz", "has_sig": false, "md5_digest": "b5f04752daee1183141026a2e91ba238", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12166, "upload_time": "2018-09-22T11:12:59", "url": "https://files.pythonhosted.org/packages/0c/e8/4e68d9a50a3ee78c2f96743aad390d37b1ffebb65eb3a1ec5cb8bde3e563/PodSixNet-0.11.0.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "a264bc3058c149a932dac59758928cf5", "sha256": "3f763eb5896a1ea960a1f71c6cba812908438135df9f7a0d958ae62230ac4b1b" }, "downloads": -1, "filename": "PodSixNet-0.8.tar.gz", "has_sig": false, "md5_digest": "a264bc3058c149a932dac59758928cf5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9184, "upload_time": "2017-11-11T11:57:12", "url": "https://files.pythonhosted.org/packages/8d/f4/1bb757b63272dc3e11915076d3f378eb16b5468dcbb4acfea77761c58994/PodSixNet-0.8.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "de7b624e09f27646174f101c08b4a9be", "sha256": "4752829a626e19a7f17965a6357b79ca567cbc3f0867dd79fb9c206d74fa9268" }, "downloads": -1, "filename": "PodSixNet-0.9.tar.gz", "has_sig": false, "md5_digest": "de7b624e09f27646174f101c08b4a9be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12684, "upload_time": "2017-11-11T12:46:11", "url": "https://files.pythonhosted.org/packages/22/13/3747f7571e23c9a6ba7409f180d28867f5cdf0f829a2b8bfaaa4898760fc/PodSixNet-0.9.tar.gz" } ], "0.9.3": [ { "comment_text": "", "digests": { "md5": "7f357bbe1715d9dbd3eadcc48ffd0daf", "sha256": "5da099333f884d5c34c5c10e05a91a38fa5699655eece8b7c5ada6a843cd0a1f" }, "downloads": -1, "filename": "PodSixNet-0.9.3.tar.gz", "has_sig": false, "md5_digest": "7f357bbe1715d9dbd3eadcc48ffd0daf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12699, "upload_time": "2018-01-30T07:42:56", "url": "https://files.pythonhosted.org/packages/0a/73/a3fc698c26712760e3c41f110b91db6ad5785f7b2c203e64523dbcd44a63/PodSixNet-0.9.3.tar.gz" } ], "0.9.4": [ { "comment_text": "", "digests": { "md5": "ad27aae7fdb37a6c648459d66ad21967", "sha256": "0f06ee93dcaa8461d30a4c575d3c54c723dec2d454aac661af8ce4007353e9e6" }, "downloads": -1, "filename": "PodSixNet-0.9.4.tar.gz", "has_sig": false, "md5_digest": "ad27aae7fdb37a6c648459d66ad21967", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12775, "upload_time": "2018-02-22T08:44:06", "url": "https://files.pythonhosted.org/packages/a1/8a/4ebc82b45fa5b1d998e9d8db19f68bd1c527f9baee8c2040d8269349b334/PodSixNet-0.9.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b5f04752daee1183141026a2e91ba238", "sha256": "5c235a73eddbabe8169ea7b51b115e55ce17d126574bebcbcee37d3d1b414e48" }, "downloads": -1, "filename": "PodSixNet-0.11.0.tar.gz", "has_sig": false, "md5_digest": "b5f04752daee1183141026a2e91ba238", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12166, "upload_time": "2018-09-22T11:12:59", "url": "https://files.pythonhosted.org/packages/0c/e8/4e68d9a50a3ee78c2f96743aad390d37b1ffebb65eb3a1ec5cb8bde3e563/PodSixNet-0.11.0.tar.gz" } ] }