Reputation: 51
I'm developping a video game on both pc and android using libgdx. And i would like to connect them by Wifi or Bluetooth on a local network. The idea is to play in p2p, establishing this connection easily. Please anyone can give help or source code for that, knowing that the connections can be : android/android but also PC/PC (since libgdx allows that)? I have absolutely no idea.
Thanks
Upvotes: 5
Views: 10847
Reputation: 1229
Well because libgdx doesn't have good networking support you can write your own, but i've found that Kryonet is very good. It takes a lot of the hassle out of writing the network layer of your application and I've used it to connect mobile and desktop with no problems. Definably worth a quick view. It also has some good examples to get your up and running with a network game too.
I've also found this article by valve very usefull.
Upvotes: 8
Reputation: 3505
There is little to no documentation on it, but LibGDX does have a platform independant (Android, Desktop, iOS and GWT) socket class.
I'd link you to an example of it's usage, but as I stated; there's no written documentation/example.
However, I can give you this link as a good starting point.
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html
Upvotes: 1
Reputation: 1023
libgdx-net looks good. https://github.com/pepedeab/libGDX-Net
Ive not yet tested it myself though.
Upvotes: 0
Reputation: 25177
Networking is somewhat beyond the scope of Libgdx. There is some basic support for HTTP GET/POST/PUT, but it implies you already have a DNS name or IP address to connect to, which usually implies you have a relatively fixed "server" to connect to (not an arbitrary peer). Peer-to-peer networking is definitely beyond the scope of Libgdx.
On the upside, since Android and Desktop networking are already pretty close, you can use most any pure-Java networking infrastructure that supports peer-to-peer. See other Stack Overflow questions like: Peer-to-Peer communication options I think you'll discover that the really hard part of peer-to-peer networking is "discovery" (that is figuring the address of the peer you care about).
Upvotes: 2