Differences between revisions 2 and 3
Revision 2 as of 2006-04-24 04:02:52
Size: 546
Editor: bluepill
Comment:
Revision 3 as of 2006-04-24 06:42:35
Size: 1273
Editor: d220-238-73-98
Comment:
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
Line 21: Line 22:

== NOTES, api part 2? ==
I think I like the url idea. We could not worry about connections at all by using urls. Optional carring about connections could be implmented.

UDP and ENet are interesting things to consider for the api. UDP is connectionless.


All bits of data could be strings.

The event queue api could event be used for some of it.
{{{
pygame.events.post(e)
events = pygame.events.get()

for e in events:
    if e.type == NET:
        if e.what == NET_DATA_IN:
            print e.channel
            print e.data
        if e.what == NET_CONNECT:
            print e.ip
            print e.port
            print e.sequence_id
            print e.channel
            pass

}}}

Simple Networking For Pygame

Write a simple network library which integrates with the pygame event queue.

Basic requirements:

  • Seamless reconnection
  • Support TCP and UDP
  • use select based non blocking IO
  • network library is iterated manually (so we use our own event loops)

Potential API:

  • connect(url, onConnection, onLostConnection)
  • send(conn, data)
  • recv(conn, num_bytes)
  • listen(url, onConnection, onLostConnection)
  • poll()

Things not to worry about:

  • Object serialization

NOTES, api part 2?

I think I like the url idea. We could not worry about connections at all by using urls. Optional carring about connections could be implmented.

UDP and ENet are interesting things to consider for the api. UDP is connectionless.

All bits of data could be strings.

The event queue api could event be used for some of it.

pygame.events.post(e)
events = pygame.events.get()

for e in events:
    if e.type == NET:
        if e.what == NET_DATA_IN:
            print e.channel
            print e.data
        if e.what == NET_CONNECT:
            print e.ip
            print e.port
            print e.sequence_id
            print e.channel
            pass

SummerOfCode/SimpleNetworkingForPygame (last edited 2008-11-15 14:00:50 by localhost)

Unable to edit the page? See the FrontPage for instructions.