Git Product home page Git Product logo

podsixnet's Introduction

Note: this project uses deprecated libraries (#46) and isn't actively maintained any more.

PodSixNet - lightweight multiplayer networking library for Python games

PodSixNet is a lightweight network layer designed to make it easy to write multiplayer games in Python. It uses Python's built in asyncore library and rencode.py (included) to asynchronously serialise network events and arbitrary data structures, and deliver them to your high level classes through simple callback methods.

Each class within your game client which wants to receive network events, subclasses the ConnectionListener class and then implements Network_* methods to catch specific user-defined events from the server. You don't have to wait for buffers to fill, or check sockets for waiting data or anything like that, just do connection.Pump() once per game loop and the library will handle everything else for you, passing off events to all classes that are listening. Sending data back to the server is just as easy, using connection.Send(mydata). Likewise on the server side, events are propagated to Network_* method callbacks and data is sent back to clients with the client.Send(mydata) method.

The PodSixNet mailing list is good for getting help from other users.

For users of the Construct game making environment for Windows, there is a tutorial on doing multiplayer networking with PodSixNet, here. Thanks to Dave Chabo for contributing this tutorial.

Here is another tutorial by Julian Meyer.

Install

pip install PodSixNet

or

easy_install PodSixNet

From source

First make sure you have Python 2.4 or greater installed (python 3 also works).

Next you'll want to get the PodSixNet source.

The module is found inside a subdirectory called PodSixNet within the top level folder. There's an __init__.py inside there, so you can just copy or symlink the PodSixNet sub-directory into your own project and then do import PodSixNet, or else you can run sudo python setup.py install to install PodSixNet into your Python path. Use sudo python setup.py develop if you want to stay up to date with the cutting edge and still be able to svn/bzr up every now and then.

By default PodSixNet uses a binary encoder to transfer data over the network, but it can optionally use the JSON format or other formats supported by a serialiser which has 'dumps' and 'loads' methods. If you want to serialise your data using JSON you can change the first line of Channel.py to 'from simplejson import dumps, loads' or use the built-in json library in Python 2.6 or higher. This will allow you to write game clients in languages that can't read the 'rencode' binary format, such as Javascript.

Examples

Chat example:

  • python examples/ChatServer.py
  • and a couple of instances of python examples/ChatClient.py

Whiteboard example:

  • python examples/WhiteboardServer.py
  • and a couple of instances of python examples/WhiteboardClient.py

LagTime example (measures round-trip time from the server to the client):

  • python examples/LagTimeServer.py
  • and a couple of instances of python examples/LagTimeClient.py

Quick start - Server

You will need to subclass two classes in order to make your own server. Each time a client connects, a new Channel based class will be created, so you should subclass Channel to make your own server-representation-of-a-client class like this:

from PodSixNet.Channel import Channel

class ClientChannel(Channel):

    def Network(self, data):
        print data

    def Network_myaction(self, data):
        print "myaction:", data

Whenever the client does connection.Send(mydata), the Network() method will be called. The method Network_myaction() will only be called if your data has a key called 'action' with a value of "myaction". In other words if it looks something like this:

data = {"action": "myaction", "blah": 123, ... }

Next you need to subclass the Server class like this:

    from PodSixNet.Server import Server
    
    class MyServer(Server):
        
        channelClass = ClientChannel
        
        def Connected(self, channel, addr):
            print 'new connection:', channel

Set channelClass to the channel class that you created above. The method Connected() will be called whenever a new client connects to your server. See the example servers for an idea of what you might do each time a client connects. You need to call Server.Pump() every now and then, probably once per game loop. For example:

    myserver = MyServer()
    while True:
        myserver.Pump()
        sleep(0.0001)

When you want to send data to a specific client/channel, use the Send method of the Channel class:

channel.Send({"action": "hello", "message": "hello client!"})

Quick start - Client

To have a client connect to your new server, you should use the Connection module. See pydoc Connection for more details, but here's a summary:

Connection.connection is a singleton Channel which connects to the server. You'll only have one of these in your game code, and you'll use it to connect to the server and send messages to the server.

from PodSixNet.Connection import connection

# connect to the server - optionally pass hostname and port like: ("mccormick.cx", 31425)
connection.Connect()

connection.Send({"action": "myaction", "blah": 123, "things": [3, 4, 3, 4, 7]})

You'll also need to put the following code once somewhere in your game loop:

connection.Pump()

Any time you have an object in your game which you want to receive messages from the server, subclass ConnectionListener. For example:

    from PodSixNet.Connection import ConnectionListener
    
    class MyNetworkListener(ConnectionListener):
    
        def Network(self, data):
            print 'network data:', data
        
        def Network_connected(self, data):
            print "connected to the server"
        
        def Network_error(self, data):
            print "error:", data['error'][1]
        
        def Network_disconnected(self, data):
            print "disconnected from the server"
        
        def Network_myaction(data):
            print "myaction:", data

Just like in the server case, the network events are received by Network_* callback methods, where you should replace '*' with the value in the 'action' key you want to catch. You can implement as many or as few of the above as you like. For example, NetworkGUI would probably only want to listen for the _connected, _disconnected, and _error network events. The data for _error always comes in the form of network exceptions, like (111, 'Connection refused') - these are passed straight from the socket layer and are standard socket errors.

Another class might implement custom methods like Network_myaction(), which will receive any data that gets sent from the server with an 'action' key that has the name 'myaction'. For example, the server might send a message with the number of players currently connected like so:

channel.Send({"action": "numplayers", "players": 10})

And the listener would look like this:

    from PodSixNet.Connection import ConnectionListener
    
    class MyPlayerListener(ConnectionListener):
    
        def Network_numplayers(data):
            # update gui element displaying the number of currently connected players
            print data['players']

You can subclass ConnectionListener as many times as you like in your application, and every class you make which subclasses it will receive the network events via named Network callbacks. You should call the Pump() method on each object you instantiate once per game loop:

    gui = MyPlayerListener()
    while 1:
        connection.Pump()
        gui.Pump()

License

Copyright Chris McCormick, 2009-2015.

PodSixNet is licensed under the terms of the LGPL v3.0 or higher. See the file called COPYING for details.

This basically means that you can use it in most types of projects (commercial or otherwise), but if you make changes to the PodSixNet code you must make the modified code available with the distribution of your software. Hopefully you'll tell us about it so we can incorporate your changes. I am not a lawyer, so please read the license carefully to understand your rights with respect to this code.

Why not use Twisted instead?

Twisted is a fantastic library for writing robust network code. I have used it in several projects in the past, and it was quite nice to work with. That said, Twisted:

  • wants to steal the mainloop
  • is bloated not KISS (it implements many many different protocols)
  • has a weird template launching language when Python should do just fine
  • is not written 100% for the specfic use-case of multiplayer games

These are some of the reasons why I decided to write a library that is lightweight, has no dependencies except Python, and is dedicated 100% to the task of multiplayer game networking.

podsixnet's People

Contributors

chr15m avatar coac avatar pauliyobo avatar pfornia avatar qwertyquerty avatar selfsame avatar tdoylend avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

podsixnet's Issues

Please add if __name__ == "__main__":

I love PodSixNet and use it to teach inroductory network programming at a University. The ChatSever and ChatClient example is nearly perfect for my purposes. I have students subclass ChatSever and ChatClient, and the fact that code for creating ChatServer and ChatClient instances executes unconditionally in the example code causes problems.

Please place if __name__ == "__main__": around code that shouldn't execute when subclasses are created:

ChatClient.py

if __name__ == "__main__":
   if len(sys.argv) != 2:
       print("Usage:", sys.argv[0], "host:port")
       print("e.g.", sys.argv[0], "localhost:31425")
   else:
       host, port = sys.argv[1].split(":")
       c = Client(host, int(port))
       while 1:
           c.Loop()
           sleep(0.001)

ChatServer.py

if __name__ == "__main__":
   # get command line argument of server, port
   if len(sys.argv) != 2:
      print("Usage:", sys.argv[0], "host:port")
      print("e.g.", sys.argv[0], "localhost:31425")
   else:
      host, port = sys.argv[1].split(":")
      s = ChatServer(localaddr=(host, int(port)))
      s.Launch()

Dead project?

Was interested in using this for a game, but saw that this repo, let alone the podsixnet2 branch, haven't been active in quite some time. Is this still viable for such use?

how can I solve this error when installing podsixnet?

Hi. I've tried different times to install podsixnet with pip but the error that i get is:

Using cached PodSixNet-0.9.tar.gz
Complete output from command python setup.py egg_info:
fatal: Not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\user\AppData\Local\Temp\pip-build-_t947scg\podsixnet\set
up.py", line 14, in
version=subprocess.check_output(["git", "describe", "--tag"]).decode().s
trip(),
File "c:\users\user\appdata\local\programs\python\python36-32\lib\subpr
ocess.py", line 336, in check_output
**kwargs).stdout
File "c:\users\user\appdata\local\programs\python\python36-32\lib\subpr
ocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'describe', '--tag']' return
ed non-zero exit status 128.

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\user
AppData\Local\Temp\pip-build-_t947scg\podsixnet
I've tried from the source by clonying it, but it's still the same.

Network interruption tolerance

How can I ensure that the server does not immediately disconnect a player at the first short network interruption?
I would like that an interruption up to 5 seconds not to be viewed as a logoff.

setup.py can't find PodSixNet/version.py

How to reproduce: clone the repository and run setup.py

When I tried to run setup.py (Python 3.7 if it matters) I got this:

$ sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 13, in <module>
    exec(open("PodSixNet/version.py").read())
FileNotFoundError: [Errno 2] No such file or directory: 'PodSixNet/version.py'

It appears that version.py doesn't exist. I worked around this by just typing in the version to setup():

setup(
    version="0.10.0",
    name='PodSixNet',
    description='Multiplayer networking library for games',
    ...
)

I don't know what happened to version.py, perhaps it was removed by accident or something.

Edit: version.py is inside of .gitignore, is this the problem?

Command '['git', 'describe', '--tag', '--always']' returned non-zero exit status 128.

It is happening when I try to install the package using either pip or easy_install. There is no difference when I use either python 2.7 or 3.6

Python 2.7 traceback:

$ pip install podsixnet
Collecting podsixnet
  Using cached PodSixNet-0.9.3.tar.gz
    Complete output from command python setup.py egg_info:
    fatal: Not a git repository (or any of the parent directories): .git
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\hjpott~1\appdata\local\temp\pip-build-8ny46c\podsixnet\setup.py", line 14, in <module>
        version=subprocess.check_output(["git", "describe", "--tag", "--always"]).decode().strip(),
      File "c:\program files\python\lib\subprocess.py", line 219, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['git', 'describe', '--tag', '--always']' returned non-zero exit status 128

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\hjpott~1\appdata\local\temp\pip-build-8ny46c\podsixnet\

Python 3.6 traceback

$ pip install podsixnet
Collecting podsixnet
  Using cached PodSixNet-0.9.3.tar.gz
    Complete output from command python setup.py egg_info:
    fatal: Not a git repository (or any of the parent directories): .git
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\HJPOTT~1\AppData\Local\Temp\pip-build-5nq253r5\podsixnet\setup.py", line 14, in <module>
        version=subprocess.check_output(["git", "describe", "--tag", "--always"]).decode().strip(),
      File "c:\program files\python3.6\lib\subprocess.py", line 336, in check_output
        **kwargs).stdout
      File "c:\program files\python3.6\lib\subprocess.py", line 418, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['git', 'describe', '--tag', '--always']' returned non-zero exit status 128.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\HJPOTT~1\AppData\Local\Temp\pip-build-5nq253r5\podsixnet\

The easy_install had a slightly longer stacktrace:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\program files\python3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python3.6\Scripts\easy_install.exe\__main__.py", line 9, in <module>
  File "c:\program files\python3.6\lib\site-packages\setuptools\command\easy_install.py", line 2265, in main
    **kw
  File "c:\program files\python3.6\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "c:\program files\python3.6\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "c:\program files\python3.6\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\program files\python3.6\lib\site-packages\setuptools\command\easy_install.py", line 410, in run
    self.easy_install(spec, not self.no_deps)
  File "c:\program files\python3.6\lib\site-packages\setuptools\command\easy_install.py", line 665, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "c:\program files\python3.6\lib\site-packages\setuptools\command\easy_install.py", line 695, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "c:\program files\python3.6\lib\site-packages\setuptools\command\easy_install.py", line 876, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "c:\program files\python3.6\lib\site-packages\setuptools\command\easy_install.py", line 1115, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "c:\program files\python3.6\lib\site-packages\setuptools\command\easy_install.py", line 1101, in run_setup
    run_setup(setup_script, args)
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 251, in run_setup
    raise
  File "c:\program files\python3.6\lib\contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 198, in setup_context
    yield
  File "c:\program files\python3.6\lib\contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 169, in save_modules
    saved_exc.resume()
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 144, in resume
    six.reraise(type, exc, self._tb)
  File "c:\program files\python3.6\lib\site-packages\pkg_resources\_vendor\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 157, in save_modules
    yield saved
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 198, in setup_context
    yield
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 248, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 278, in run
    return func()
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 246, in runner
    _execfile(setup_script, ns)
  File "c:\program files\python3.6\lib\site-packages\setuptools\sandbox.py", line 47, in _execfile
    exec(code, globals, locals)
  File "C:\Users\HJPOTT~1\AppData\Local\Temp\easy_install-00ahp3gk\PodSixNet-0.9.3\setup.py", line 14, in <module>
  File "c:\program files\python3.6\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "c:\program files\python3.6\lib\subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'describe', '--tag', '--always']' returned non-zero exit status 128.

Typo in podsixnet2 package on PyPi

Hi Chris,

When installing podsixnet2 as follows, I get an error about not being in a git repo:

$ pip install podsixnet2
Collecting podsixnet2
  Using cached podsixnet2-2.0.1.tar.gz (12 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/mond/python-virtualenvs/cocos2d_pyglet-1.5/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vaosdd_x/podsixnet2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vaosdd_x/podsixnet2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-rofalij9
         cwd: /tmp/pip-install-vaosdd_x/podsixnet2/
    Complete output (10 lines):
    fatal: not a git repository (or any of the parent directories): .git
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-vaosdd_x/podsixnet2/setup.py", line 17, in <module>
        __version__ = subprocess.check_output(["git", "describe", "--tag", "--always"]).decode("utf8").strip("\n")
      File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
      File "/usr/lib/python3.8/subprocess.py", line 512, in run
        raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['git', 'describe', '--tag', '--always']' returned non-zero exit status 128.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Which happens because in the setup.py file it incorrectly has the directory as podsixnet rather than podsixnet2

versionfile = "podsixnet/version.py"
if not os.path.isfile(versionfile):
    # assume git checkout
    __version__ = subprocess.check_output(["git", "describe", "--tag", "--always"]).decode("utf8").strip("\n")
else:
    # created by pip
    exec(open(versionfile).read())

After changing versionfile I am able to install it.

I think it would be useful to update the 'Project description' page to explain why there are two packages and that they are functionally equivalent (as I had to delve into previous issues #26 and PRs #35 #37 to find out 😄).

Many thanks.

[RFC] port codebase to python3

I came across this library a while ago while musing about my new game's architecture. I'd like to use this library, but not in its current state. Therefore, I have put in some considerable effort to revitalize the code base to use python3. However, it came to my attention that asyncore (and consequently asynchat) are being deprecated [1].

The recommended upgrade path is to use asyncio. Unfortunately, asyncio uses an explicit async model. This means that if we decide to go the asyncio route, games using this library will also have to do asyncio-style coroutine programming.

I have no objections to using asyncio, but I could see there being some concern. I'd like to hear more thoughts on this.

[1] https://docs.python.org/3.5/library/asyncore.html (see the note at the top)

Wrap async_chat instead of inheriting?

Currently, Channel inherits from async_chat. This means it gets the really wonky async_chat.getattr method, which causes problems like this.

I propose that instead of inheriting, we make Channel (and also EndPoint, by extension) a wrapper around async_chat. That way, error messages can be more helpful and PodSixNet can move closer to PEP-8 by not having capitalized methods.

I'm willing to do this and submit a PR if @chr15m thinks this is a good idea.

Pip packaging

Are you considering maintaning an pip package? It would allow the others to easily add this awesome project as a dependency to their projects.

Documentation / comments in the code

Could you add some comments in the library files to document that's happening and what the variables represent ?
The init definition in Server.py, does the "listeners=5" statement mean it will not take more than 5 clients connected at a time ?
I'm using your library (very happily) in a multi player server for JanusVR and it seems it works very well so far, but I do hope you could add some info to some of the files :D

I try to pass on Bytes data,and get Error

I try to pass on JPEG Bytes data

and I get this Error

{'action': 'error', 'error': UnicodeDecodeError('utf-8', b'\xff\xd8\xff\xc0\x00\x11\x08\x00\xf.....', 0, 1, 'invalid start byte')}

what should I do

Deployment recommendations?

Does anybody have any recommendations for deployment? I have a simple game coded up and I want to be able to play test with another friend living in another state. I don't need to be able to scale the game for multiple sessions or more than 10 connections. Are there any simple and cheap ways to host a game server? AWS, Heroku, or configuring my router? Thanks!

Adapting to Python 3

trying to run Server.py:

ServerTestCase
--------------
E
======================================================================
ERROR: runTest (__main__.ServerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gus/PodSixNet/Server.py", line 83, in setUp
    self.server = TestServer(channelClass=ServerChannel)
  File "/home/gus/PodSixNet/Server.py", line 22, in __init__
    self.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
AttributeError: 'TestServer' object has no attribute 'setsockopt'

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

Disconnecting From Server when wifi is down due to screen lock or sleep.

First, I just want to say big thanks for this aiming piece of art. truly helpful and useful.
I have a made a game using Pythonista for iOS and the game works perfectly but whenever I put the phone to sleep, the connection gets lost with the Server because most iPhones drop wifi while they are asleep. is there a way to have that connection hang until I am back online next time or there is no way around.
where is the built in function _disconnected which clients received?
Thank you and I hope it makes sense.

Required callbacks?

I have used a packet sniffer and to my shock, the packets are perfectly unprotected and are out there just waiting to be misused. Can you please add an ability to have a callback for both incoming and outgoing data for encryption purposes?

Podsixnet with Asyncio.

Hi. First of all thank you for this excellent project. Wanting to implement a chat following the example provided here, I would like not to use threads, as it is also recommended, but to use asyncio, which as I understand it, is the best method to manage coroutines. I modified the chatclient.py file and it does not give an error, however the chat messages are not sent between the various clients. Can you help me understand what I need to change?
Thank you. The example is the one you provided, only with a few minor modifications.

from future import print_function
import asyncio
import sys
from time import sleep
from sys import stdin, exit
from PodSixNet.Connection import connection, ConnectionListener

from _thread import *

class Client(ConnectionListener):
def init(self, host, port):
self.Connect((host, port))
print("Chat client started")
print("Ctrl-C to exit")
# get a nickname from the user before starting
print("Enter your nickname: ")
connection.Send({"action": "nickname", "nickname": stdin.readline().rstrip("\n")})
# launch our threaded input loop
loop = asyncio.get_event_loop()

async def Loop(self):
    connection.Pump()
    self.Pump()

async def InputLoop(self):
    # horrid threaded input loop
    # continually reads from stdin and sends whatever is typed to the server
    while 1:
        connection.Send({"action": "message", "message": stdin.readline().rstrip("\n")})

def Network_players(self, data):
    print("*** players: " + ", ".join([p for p in data['players']]))

def Network_message(self, data):
    print(data['who'] + ": " + data['message'])

# built in stuff

def Network_connected(self, data):
    print("You are now connected to the server")

def Network_error(self, data):
    print('error:', data['error'][1])
    connection.Close()

def Network_disconnected(self, data):
    print('Server disconnected')
    exit()

if name == 'main':
if len(sys.argv) != 2:
print("Usage:", sys.argv[0], "host:port")
print("e.g.", sys.argv[0], "localhost:31425")
else:
host, port = sys.argv[1].split(":")
c = Client(host, int(port))
while 1:
asyncio.run(c.Loop())
sleep(0.001)

async leads to invalid syntax with python 3.7.0

Due to the changes in python 3.7 async is now a keyword.

This results in the following Error:

$ python3.7 ChatServer.py localhost:123456
Traceback (most recent call last):
  File "ChatServer.py", line 7, in <module>
    from PodSixNet.Server import Server
  File "/tmp/PodSixNet/examples/PodSixNet/Server.py", line 4
    from PodSixNet.async import poll, asyncore
                       ^
SyntaxError: invalid syntax

After the cloning, I moved the PodSixNet/PodSixNet directory to PodSixNet/example/PodSixNet. With python 2.7 and 3.4 the ChatServer.py runs as expected. But not with 3.7.

Renaming async.py and the imports in Channel.py and Server.py to the non-keyword "notasync" seems to fix this behaviour.

Can somebody verify this error with python 3.7

Replacement for Serializable

I realized in the new 0.10.0 update PodSixNet.rencode.serializable was removed. I am wondering if there is a replacement because all of my code breaks on 0.10.0 so I'm sticking to the old version.

Some questions

I know, that i can send the commands to the server and receive it in client without direct access to the network class via queue, but it causes some problems, e.g. when the queue is empty, the program will give an error, when i'm trying to read an informations from the queue, and in my opinion it's not enough elegant to do this using queue. Is any way to send and receive the messages from and to server and some specific clients which send a message to the server. FOr Example, some client is moving through the map, and asking, what is located around you. Which method use to reply to specific clients?

supporting transmission of data through the UDP protocol

Hello there.
Currently PodSixNet supports the transmission of data through the TCP protocol.
Could we allow it to support UDP with a parameter in the server instance? such as:
s = server(protocol=UDP)
I'd be more than happy to work on this issue, but I'd first like to know what you all think.

Inability to see disconnections

I am unable to see whether someone's connection is dead.
Consider this:
I create a server.
Bob logs in to my server.
Bob kills his game with task manager.
Bob's player is still on the server.
Could you please either
1: Tell me if the library has something to see if a player disconnected or
2: Add in such a feature?
I know a way to get around this -- ping the clients at regular intervals, but that is more work for the server/more packets being sent. Besides, then comes in the question of how often? 1 minute? 3? 15?

connection.Connect() won't work

I am new to PodSixNet so if I'm just using it wrong sorry.
(I'm following the Quick Start guide)

When I do connection.connect("127.0.0.1") i get this Error:
Traceback (most recent call last): File "C:\Users\olive\Documents\Python\Pygame Zero\Online Test\client.py", line 21, in <module> connection.connect("127.0.0.1") File "C:\Users\olive\AppData\Local\Programs\Python\Python37-32\lib\asyncore.py", line 333, in connect err = self.socket.connect_ex(address) AttributeError: 'EndPoint' object has no attribute 'socket'

I have no Idea what an EndPoint is but it seems whatever the code gives as self is one and it shouldn't be.

bytes in dict don't works correctly

I am running rencode.py and I am getting those outputs in shell:

>>> d = {b"a":1}
>>> loads(dumps(d))
{'a': 1}
>>> loads(dumps(d)) == d
False

Same for when bytes are value of dictionary too. I am using python3.8.0

Manual

No offense but how come there's no manual or comprehensive tutorial on how to use this software/facility

Julian meyer and the rest have proven unfruitful to me..... Idk wah to do again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.