Closed GoogleCodeExporter closed 9 years ago
it took me about 10 minutes to modify the xna sample to have loopback:
run the server code in it's own thread (execute in XnaClient.Program.Main
before invoking the Game.Run, and do a thread.Join() after the Game is finished
exiting)
and then for the client and server, set config.LocalAddress =
IPAddress.Loopback;
this is probably better than netpeer auto-loopback because it uses the existing
workflows for normal client/server stuff
Original comment by jas...@novaleaf.com
on 4 Sep 2011 at 10:43
In my particular case I'm not using server-client topology, but rather
peer-to-peer. And there's no such thing as a server in the game, all clients
simulate the game on their own, only commands are sent through network.
Anyway, for my case, I've added this simple method to NetPeer, and it worked
perfectly so far:
public void SendMessageToLoopback(NetOutgoingMessage msg) {
if (msg == null)
throw new ArgumentNullException("msg");
NetIncomingMessage im = CreateIncomingMessage(NetIncomingMessageType.Data, msg.LengthBytes);
im.Write(msg.PeekDataBuffer(), 0, msg.LengthBytes);
ReleaseMessage(im);
}
Original comment by smiledi...@joystickninjas.com
on 8 Sep 2011 at 2:36
The solution in comment 1 is probably preferable in many situations; but I've
added a SendUnconnectedToSelf() in case you really need to reduce overhead and
latency for self sends. Revision 270.
Original comment by lidg...@gmail.com
on 2 Nov 2011 at 9:48
Original issue reported on code.google.com by
smiledi...@joystickninjas.com
on 22 Aug 2011 at 1:37