Java libgdx(desktop/android) multiplayer game how to

csga5000 picture csga5000 · May 23, 2013 · Viewed 12k times · Source

I have a game called wizard wars that I have been working on. This game needs to allow 2 players to play at one time, and would need a TCP connection to communicate spell creation/destruction ect., and a UDP connection to handle locations ect. It would have a client and a host side. That being said my program is designed to run on Android. All of the tutorials/information I have found online has been for JApplets or something like that. So what I would like is some help with ever short code examples of how to set up/use connections, or just a link to some sufficiently helpfull information on how to set up the actual connections.

Answer

pedronveloso picture pedronveloso · May 24, 2013

The best approach (or at least 1 approach) would be to use normal HTTP requests : http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html

You create a webservice implementing REST and create calls for both updating and consuming data.

Alternatively, if you're just going to use Android and Desktop you may also use WebSockets : https://github.com/pepedeab/libGDX-Net