Hi,

Networking module is finally in state allowing to test it and show
something working, so I wrote new blog post describing changes and showing
features. You can find it here:
http://pygame-networking.blogspot.com/2012/07/gsoc-journal-client-tests.html

Greetings,
Szymon Wróblewski

2012/6/21 Szymon Wróblewski <[email protected]>

> I added documentation about available events:
>
> http://pygame_network.readthedocs.org/en/latest/source/pygame_network.html#events
>
> 2012/6/21 Szymon Wróblewski <[email protected]>:
> >> connection.register('echo', ('user', 'msg'))
> >
> >> You would also probably want a separate 'protocol' object on which you
> >> would register the messages, so
> >> that you can reuse it for several connections.
> >
> > pygame_network.register method is in fact
> > pygame_network.packets.PacketManager.register, which stores all
> > registered packet types and maps them to integers to reduce packet
> > size (those integers must be unique), but if you see use for separate
> > managers all I need to do is define __init__ for it, to override class
> > variables with instance variables.
> >
> >> connection = pygame_network.connect('localhost', 10000)
> >
> > I plan to create Connection class so pygame_network.connect will just
> > init global connection variable to use by Receiver and SyncObject (it
> > can be overridden with initialization parameter) and you can create
> > more connections with this class.
> > example:
> > connection = pygame_network.Connection('localhost', 10000)
> >
> > I chose pyenet as a low level socket library, so protocol (UDP,
> > Reliable UDP and other variants) can be selected with enet flags
> > during creation of packet or sending it. This is my answer for need of
> > both TCP and UDP protocols.
> >
> >> The network events then would have a connection property telling you
> >> from which connection they came.
> >
> > I agree with idea of adding connection to network event. So summing
> > up, it will look like this:
> > e.type = NETWORK # event type
> > e.connection # weakref of connection from which the packet comes
> > e.channel # channel of connection
> > e.packet # packet object
> > e.packet_id # packet identifier
> > e.net # packet type (to allow e.net == echo)
> >
> > 2012/6/21 Radomir Dopieralski <[email protected]>
> >>
> >> On Wed, Jun 20, 2012 at 8:02 PM, Szymon Wróblewski <[email protected]>
> wrote:
> >> > I focused currently on creating client api and not everything is
> complete
> >> > yet, but client side could look like this:
> >> > (same code with syntax highlighting: http://pastebin.com/CiypsKpC)
> >> >
> >> > import pygame
> >> > import pygame_network
> >> >
> >> > pygame.init()
> >> > # create connection
> >> > pygame_network.connect('localhost', 10000)
> >> > # connection overlay
> >> > host = pygame_network.client.Host()
> >> > # register new packet type
> >> > # it will call pygame_network.packets.PacketManager.register()
> >> > echo = pygame_network.register('echo', ('user', 'msg'))
> >> > name = raw_input('name: ')
> >>
> >> I really hate to see the globals here. Wouldn't it be better to have
> >> it something like this?
> >>
> >> connection = pygame_network.connect('localhost', 10000)
> >> connection.register('echo', ('user', 'msg'))
> >>
> >> then you can connect to different servers with different protocols at
> >> the same time.
> >> The network events then would have a connection property telling you
> >> from which connection they came.
> >> You can also then close one of the connections independently from
> others.
> >> You would also probably want a separate 'protocol' object on which you
> >> would register the messages, so
> >> that you can reuse it for several connections.
> >>
> >> What do you think?
> >>
> >>
> >> --
> >> Radomir Dopieralski
>

Reply via email to