Hi,

Twisted does a lot of things, but the goal of this project is easy, and
simple.  I don't think twisted does that for a very specific set of game
style networking.  People have tried to use twisted in the past with pygame
(for over 7 years), but I don't think it meets the simplicity levels
required considering the lack of successfully implemented networking in a
game.  Twisted does events as callbacks, and we're trying events as objects.

See the features in the enet library, which has been used successfully in
real time games: ( http://enet.bespin.org/Features.html)  Those are the
main features, and it does meet the requirements for many types of games.

cu.


On Tue, Jul 3, 2012 at 3:41 AM, Ryan Hope <[email protected]> wrote:

> I just looked more at the code you have posted on your blog and it
> seems like you are recreating much of what Twisted already does. Why
> are you not just creating better PyGame/Twisted integration?
>
> On Mon, Jul 2, 2012 at 9:38 PM, Ryan Hope <[email protected]> wrote:
> > Can someone explain to me why integrating network packets with pygame
> > events is a good idea? It was my understanding that the pygame event
> > buffer can only hold a limited number of events before events get
> > lost.
> >
> > On Mon, Jul 2, 2012 at 8:19 PM, Szymon Wróblewski <[email protected]>
> wrote:
> >> 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
> >>
> >>
> >
> >
> >
> > --
> > Ryan Hope, M.S.
> > CogWorks Lab
> > Cognitive Science Department
> > Rensselaer Polytechnic Institute
>
>
>
> --
> Ryan Hope, M.S.
> CogWorks Lab
> Cognitive Science Department
> Rensselaer Polytechnic Institute
>

Reply via email to