vedi0boy
vedi0boy

Reputation: 1040

LibGDX - Connecting cross-platform clients to a server (HTML5/GWT, iOS, Android and Desktop)

Over the weekend I set up all the networking for a game I was making. I was basing it off this tutorial: GamesFromScratch.com Basic LibGDX Networking. It said that it only supported TCP but I was okay with that since I could figure something out and there was a bunch of material online on how to make real time games without UDP. After I finished, I tested it on desktop, android and then on HTML5/GWT. Desktop and android worked but GWT didn't. I did some research and found that Gdx.net does not support GWT, the article didn't warn me :/ Basically now I am trying to find an alternative solution that will work with ALL libgdx platforms.

I looked into Websockets with Socket IO. Here are the Java libraries I found for the: Client and Server. The server library says it works well with the client one which is reassuring. It seems like a good solution but I have a few questions:

- Would the client library work on all platforms? It seems that it would work on android and desktop since they don't have to convert to another language but what about GWT and iOS? And not only just work, but also be able to connect to the server using the server library.

- Is there anything I need to watch out for when using websockets?

Thanks.

EDIT: I did a little bit more research and I found Jetty. I looked around and it seems to be GWT compatible, I just need to know if it is also iOS compatible. And could I use Jetty as my server api also?

Upvotes: 5

Views: 2606

Answers (2)

vedi0boy
vedi0boy

Reputation: 1040

I did it. I did a lot of research in the past few days and I finally found this post on stackoverflow.com that told me about 2 great libraries including one I could use with the client that supports GWT.

It works great, the only thing is that I will have to use 2 WebSocket libraries for the client, one on html and another for all the other platforms but that's okay, at least it works.

The libraries are: Client and Server.

Upvotes: 2

Radosław Bojba
Radosław Bojba

Reputation: 21

you can use Kryonet which provide network for PC, Android and iOS(not tested). On this library you can build server side or client side app. In GWT you have WebSocket and you must use other library to connect with server. When you start game, you can inject right implementation client for GWT can be example: gwt-websockets and kryonet for other platform.

Next, you must change kryonet default serialization implementation by own, supporting json. In my project i use LibGDX json serialization.

Currently, i don`t have support for gwt but i will work on it in near feature.

Jetty in my opinion is too heavy for client and isn`t simple so much. But witch Spring, you can easy create server service based on REST or http communication.

Upvotes: 0

Related Questions