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

Re: [pygame] Easy networking module - feedback needed



I personally would like to see an official Twisted reactor for pygame.

On Wed, Jun 20, 2012 at 3:01 PM, DR0ID <dr0id@xxxxxxxxxx> wrote:
> On 20.06.2012 20:02, Szymon WrÃblewski wrote:
>
>
> # version 1:
> while True:
> for e in pygame.event.get()
> if e.type == NETWORK and isinstance(e.packet, echo):
> user, msg = e.packet
> print '%s: %s' % (user, msg)
> host.send(echo('me', raw_input())
>
>
> Hi
>
> if you go with this pattern then I would suggest to avoid 'isinstance(...)'.
> I would suggest to do it like the key events in pygame:
>
> if e.type == pygame.KEYDOWN:
> ÂÂÂ if e.key == pygame.K_ESCAPE:
> ÂÂÂ ÂÂÂ # react
>
> So my suggestion would be something similar for networking packets:
>
> if e.type == pygame.NETWORK:
> ÂÂÂ if e.packet_type == echo:
> ÂÂÂ ÂÂÂ # do whatever needs to be done here
>
>
> Maybe there is a better name for 'packet_type'
>
> ~DR0ID
>



-- 
Ryan Hope, M.S.
CogWorks Lab
Cognitive Science Department
Rensselaer Polytechnic Institute