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

Re: [pygame] SOC Proposal: Networking for Pygame



I also don't like the idea of handling data in events in the main loop. I 
would be more inclined to create a custom protocol object that posts my own 
application specific objects to the SDL event queue, based on what comes in 
on the network. There could be a standard protocol class that allows you to 
send any event object over the network and it gets posted to the remote queue 
if it matches a list of allowed network events. That way games with basic 
needs can simply use the standard event propagation protocol, and games with 
more complex network needs can implement a custom protocol, possible 
inheriting from existing protocols.

There could also be TCP and UDP versions of the event propagation protocol. 
The UDP version could have lightweight receive confirmations, and allow you 
to do both lossless and lossy sends.

It would still be easy enough to have TCP and UDP protocol objects that post 
the data in event to the SDL queue, for people who really wanted to process 
their low level network events in the main loop.

-Bryce

On Monday 08 May 2006 00:27, Brian Fisher wrote:
> On 5/7/06, Rene Dudfield <renesd@xxxxxxxxx> wrote:
> >  Using the pygame event queue means that all event management is done
> > through the same api.  So people who already understand pygame events
> > can use networking too.
>
> That's a Red Herring, and it doesn't apply to the issue I'm talking
> about. You don't need to use the same event queue in order to get the
> benefit of people's knowledge and understanding. If you have the
> network have it's own seperate queue that acts similarly to the pygame
> one, but can be read and processed in a seperate loop, then it's still
> true that "people who already understand pygame events can use
> networking too"
>
> The issue I'm talking about is whether pygame.event.poll and
> pygame.event.get would be the only functions that can get network
> packets and/or lobby/matchmaking events...I still don't see any reason
> why a single line of game code to process packets should be sitting in
> my main event loop.
>
> ...I'm just working through what code I would write in my
> pygame.event.get loop if net messages came through there, and it would
> just be something that buffers the net messages so the code that
> actually uses it can read it, or forwards them on to registered
> listeners... So why shouldn't the "simple to use networking" module
> help me out by not making me write that extra boilerplate?
>
> I can see that it would be easier to process the net stuff in that
> main loop if you are writing a small example, or a pygame app that's
> all in one file, but is there anybody here who would write anything
> more than either message dispatch/buffering for net events in their
> main event loop in a real network game?
>
> > SDL_net does use the event queue... well they wrote a different
> > implementation of it which they call fast events.
>
> Are we talking about the same SDL_net? Do you mean this one:
> http://www.libsdl.org/projects/SDL_net/
>
> because that SDL_net sure looks like nothing more than a very thin
> (simple?) wrapper over TCP and UDP to me
>
> I don't see the word event used anywhere in it's docs
> http://jcatki.no-ip.org/SDL_net/SDL_net.html
> and I don't see events used in the SDL_net sample code either
>
> >See the fastevents module in pygame.
>
> I don't know anything about fastevents, I can't find the "fastevents"
> module in the pygame docs:
> http://www.pygame.org/docs/ref/index.html
>
> I'm curious about them though, got a link?
>
>
> (PS. if there is a better home for discussion/suggestions/criticism of
> network proposal stuff than being mailed to this list, please let me
> know where it should go)