Net play

Hi all,

I was wondering if there is a “good” way to implement a netplay system.
Consider a game with 2 players which can be either local or distant.

How to mix the event loop, grabbing local events, with network events ?

If this question is too complex to be solved here, never mind.

Thanks
Julien_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr

How to mix the event loop, grabbing local events, with network events ?
When I launch a “network” game, I set up socket listener threads on
each player’s machine that block on input (that is why they are in a
separate thread) for each event type. When an event happens that needs
to be sent across the wire, the creator of that event sends out its
message to the appropriate multicast group. The receiving socket then
creates an SDL_Event out of the message and pushes that onto the event
queue. The event handling code is agnostic about the source of the
message, which I think is a good thing. Error checking should be done
along the way in several places, of course.

For an example implementation:
Multicast backbone code:
http://code.google.com/p/xor/source/browse/trunk/src/multicast/

Proxy pattern for mouse events
listener object:
http://code.google.com/p/xor/source/browse/trunk/src/event/mouse/MouseSkeleton.cpp
multicast object:
http://code.google.com/p/xor/source/browse/trunk/src/event/mouse/MouseStub.cpp
Parent class: http://code.google.com/p/xor/source/browse/trunk/src/event/mouse/Mouse.cpp

Hope this helps!

John

Mixing the event loop with network events? It’s already done: You should check out Bob Pendleton’s NET2 lib (and FastEvents, a dependency) at http://www.gameprogrammer.com/net2/net2-1.htmlIt’s a layer on top of SDL_net that tosses networking events onto the event queue so you can deal with them in the same way as your other events. As for passing actual info, I combined the packing functions from Beej’s sockets tutorial with Net2 into Jnet (found on my page)… But I wasn’t able to get a non-loopback connection. It was probably my fault in the connection process, but I haven’t touched it in a while.Jonny DDate: Mon, 11 Aug 2008 09:21:36 +0000From: clementj2005 at yahoo.frTo: sdl at lists.libsdl.orgSubject: [SDL] Net playHi all,I was wondering if there is a “good” way to implement a netplay system.Consider a game with 2 players which can be either local or distant.How to mix the event loop, grabbing local events, with network events ?If this question is too complex to be solved here, never mind.ThanksJulien

Envoy? avec Yahoo! Mail.Une boite mail plus intelligente.

Thank you guys ^^

Julien_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr