Java libgdx(desktop/android) multiplayer game how to

12,748

Solution 1

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

Solution 2

For those who don't read comments, but still looking for tcp client.

You can use KryoNet which supports Desktop and Android https://github.com/EsotericSoftware/kryonet

Solution 3

Have you guys looked at the multiplayer super jumper tutorial? Its written using AppWarp and is being actively used in the libgdx community as well.

Share:
12,748
csga5000
Author by

csga5000

I work for Guru Technologies writing iOS, web, and android apps.. as well as anything else our clients ask for. After working in the field for users for a company that contracts with various businesses I've worked with so many technologies it's not worth listing and I'll probably be outdated next week. At time of writing, my favorite language for an API is Ruby (with grape, sinatra, or rails), for a frontend web I like to use angular, and for mobile I prefer flutter. I'm excited about the coming of language interoperability, new technologies based on web assembly, increased use of AI in software, self driving car tech, and fuchsia.

Updated on June 04, 2022

Comments

  • csga5000
    csga5000 almost 2 years

    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.

  • gregory boero.teyssier
    gregory boero.teyssier about 10 years
    Can WebSockets not be used with html5?
  • JohnyTex
    JohnyTex over 9 years
    Thx dude! This seems to be exactly what I am looking for!