[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Soc: Simple Networking



Some interest has been expressed in completing this:

http://wiki.python.org/moin/SummerOfCode/SimpleNetworkingForPygame

as a Summer of Code project.

We need to define an API to ensure that any work done is usable, and
integrated well into pygame.

Based on the above wiki page, I have come up with the below interface
definition. Please supply some comments and criticism so we can get
this right.

-Sw.


class Server(object): def __init__(self, interface, port, transport=TCP|UDP): """ Opens a socket and starts listening on a port. """ pass

   def poll(self):
       """
       Iterates the network selection queue, and posts events to
pygame event queue.
       """
       pass

   def disconnect(self):
       """
       Breaks all client connections.
       """
       pass

class Client(object):
   def __init__(self, interface, port, transport=TCP|UDP,
reconnect_timeout=10):
       """
       Attempts to Opens a socket and starts listening on a port.
Reconnects automatically.
       """
       pass

   def poll(self):
       """
       Iterates the network selection queue, and posts events to
pygame event queue.
       """
       pass

   def disconnect(self):
       """
       Break the socket connection.
       """
       pass

   def send(self, data):
       """
       Sends data down socket.
       """

Events:

NETCONNECT:
   server/client instance, ip, port, sequence_id, channel

NETRECV:
   server/client instance, ip, port, data

NETDISCONNECT:
   server/clent instance, ip, port, channel