0
\$\begingroup\$

So i'm struggling with making my cross-platform client side to work, specifically on HTML part. I have java server that is responsible for all the controls and events, and I control it via netty-socketio. Client is Libgdx, and desktop version works flawlessly when using io.socket.client.IO class and Gson for json serialization. The implementation of game is clunky, but everything works and multiple clients can join, move and play.

Everything went south when i tried to launch html client. Nothing seems to be working and i have ran out of ideas of what to do. This is the errors i get

[ERROR] Line 4: The import org.json cannot be resolved
[ERROR] Line 5: The import org.json cannot be resolved
[ERROR] Line 11: JSONObject cannot be resolved to a type
[ERROR] Line 12: JSONException cannot be resolved to a type

together with

[ERROR] Line 15: No source code is available for type io.socket.client.Socket; did you forget to inherit a required module?
[ERROR] Line 17: No source code is available for type com.google.gson.Gson; did you forget to inherit a required module?
[ERROR] Line 20: No source code is available for type com.google.gson.GsonBuilder; did you forget to inherit a required module?
[ERROR] Line 45: No source code is available for type io.socket.client.IO; did you forget to inherit a required module?
[ERROR] Line 47: No source code is available for type java.net.URISyntaxException; did you forget to inherit a required module?

Quick googling says, that i cannot use io.socket.client and gson in GWT. So i'm here, trying to find some guidance, because everything I run into seems to be old and outdated. I hope someone can help me:

  1. Is it possible to run single libgdx code for all platforms and communicate with server via socket (or anything at this point)
  2. What libraries/repositories should I use to achieve this.
  3. How exactly do i configure my html part to work correctly (I failed to find a single decent tutorial when using libgdx socket with html)
\$\endgroup\$
0
\$\begingroup\$

For web support (support cross platforms) you need to use libraries that do not use Java features such as reflection (Gson problem). If possible use libraries implemented in libgdx. In your cese use https://github.com/libgdx/libgdx/wiki/Reading-and-writing-JSON.

There is always some peace of platform specific code. For this write java interface class and implement it for every specific platform (also test it ;)). Pass this object throw game constructor in your core game. For more see: https://github.com/libgdx/libgdx/wiki/Interfacing-with-platform-specific-code

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.