Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibGDX - HTML5 runner, with networking?

I have a 2D game that I created using the LibGDX Engine. The game was created for Desktop.

Also developed a server for the game.

I use the Netty.io networking library to communicate between the server and the client.

Everything works fine, but I want to let users that has no Java installed to play, and the solution I found is use the HTML5 runner that LibGDX offers.

But if I convert it to HTML5, I have to re-do the networking part for the HTML5 client with websockets, and add a support for a websocket connection in the server, is that correct?

Is there any other solution for this?

like image 842
Ben Beri Avatar asked Sep 03 '18 15:09

Ben Beri


1 Answers

On the Netty.io website you linked, I see support for Websockets, but no JS implementation. So the answer depends if there is a JS implementation for Netty.io available (like Socket.io has clients for Java and JS).

If Netty has implementations both for Java and JS, you have to extract all methods you use to an interface that you call in your core project. The interface implementations for Android and Desktop projects would be the Java implementations you currently use, while for GWT backend you would use JSNI calls to the JS implementations.

For an example, you can see my Github project for using game services: The Google Play Games implementations are available for HTML, Desktop and Android, all implemented against the same interface and HTML implementation is using JSNI calls to Google's JS lib: https://github.com/MrStahlfelge/gdx-gamesvcs/blob/master/html-gpgs/src/de/golfgl/gdxgamesvcs/GpgsClient.java

If there is no JS implementation for Netty.io available, you will have to do it yourself or switch to another network layer.

like image 104
MrStahlfelge Avatar answered Sep 28 '22 05:09

MrStahlfelge