REST API/Path

76 views
Skip to first unread message

Scooter Willis

unread,
Jul 8, 2018, 2:43:07 PM7/8/18
to CheerpJ Developers
Based on testing and reporting/confirmation from cheerpj Java RMI doesn't work because javascript doesn't allow socket connections. RMI and any applications that depend on socket connections should probably be listed as not supported in Cheerpj. 

Now looking to do communication/posting of data to web server via REST where most of the frameworks that will do the heavy lifting for you have numerous dependencies on third party JAR libraries in particular http libraries which are required for authentication. The concern is the dependency on third-party JAR files that use low-level socket library or http interfaces that won't map well onto javascript libraries. Tyring to avoid doing a deep dive of the various frameworks to get lucky and find one that works. 

Can you provide any guidance/recommendation on a particular REST framework that will work in a cheerpj client? 

Any experience with SOAP/WSDL working in Cheerpj?

Going to assume JDBC related code would not work because of the need for a socket connection. 

Having Java applications that run in a web browser is fairly limiting if you can't do real-time data transaction to a web server. 


Alessandro Pignotti

unread,
Jul 11, 2018, 2:39:28 AM7/11/18
to CheerpJ Developers, Scooter Willis
Hello,

Browsers do not allow arbitrary connections to TCP/UDP ports, that's why you got SocketExceptions while trying to use RMI. To support HTTP connections, CheerpJ provides an XHR based HTTP/HTTPS handler. This handler is enable by default when converting an applet, for application it needs to be manually enabled by running

cjCall("java.lang.System", "setProperty", "java.protocol.handler.pkgs", "com.leaningtech.handlers");

after cheerpjInit() and before cheerpjRunMain/cheerpjRunJar

Regards,
Alessandro

--
You received this message because you are subscribed to the Google Groups "CheerpJ Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cheerpj-developers+unsub...@googlegroups.com.
To post to this group, send email to cheerpj-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/cheerpj-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/cheerpj-developers/08a1cb9e-3406-448b-ab7c-24b2e37bbdd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Leaning Technologies Limited

Alessandro Pignotti
CTO
aless...@leaningtech.com

Leaning Technologies Limited 
www.leaningtech.com

Twitter  Facebook  LinkedIn 

Scooter Willis

unread,
Jul 11, 2018, 7:57:07 PM7/11/18
to CheerpJ Developers
That fixed the problem. 

Found a lightweight REST api package with JSON support written to run on android. http://hgoebl.github.io/DavidWebb/ and it is working as well. 

It would be great if REST Jax-RS Jersey 2.5 framework worked which allows you leverage Netbeans and other IDE to generate interfaces from entity classes etc. I opened a bug report that the cherrpj compiler crashes on many of the jar files when generating the javascript library. The negative is lots and lots of JAR files that aren't needed so adds a considerable amount of code to be downloaded.

Very excited about the potential. 

Scooter Willis

unread,
Jun 21, 2019, 2:50:36 AM6/21/19
to CheerpJ Developers
Wanted to revisit the socket problem. As a fun project wanted to port Minecraft which can be run locally but requires a login process to play the game locally. 

Have you considered https://developer.mozilla.org/en-US/docs/Web/API/WebSocket  as a way to implement socket connections?

Alessandro Pignotti

unread,
Jun 21, 2019, 3:18:39 AM6/21/19
to CheerpJ Developers, Scooter Willis
Dear Scooter,

we are currently prototyping a solution to allow network connections from CheerpJ. We are of course considering WebSockets, but it should be noted that WebSockets are not _actually_ sockets, as they don't permit (for good security reasons) to connect to arbitrary hosts/ports.

About Minecraft, I suspect the biggest issue will actually be 3D rendering/graphics and not networking. A few points

-) If the login process happens through HTTP and using the standard Java stack you can try the following workaround:
cheerpjRunStaticMethod(threads[0], "java/lang/System", cjSystemSetProperty, "java.protocol.handler.pkgs", "com.leaningtech.handlers");
Call this before cheerpjRunMain/cheerjRunJar. This sets the java.protocol.handler.pkgs property to com.leaningtech.handlers and enables our custom XHR based HTTP handler.
-) Is there a way to run Minecraft offline? Possibly with some command line switch? That would make it possible to solve this problem later on.
-) As said before I think the biggest problem is going to be rendering, since it is probably implemented using native (JNI) methods. CheerpJ cannot automatically port those. Java native methods needs to be reimplemented in JS, which can be done as documented in the wiki: https://github.com/leaningtech/cheerpj-meta/wiki/Implementing-Java-native-methods-in-JS

Regards,
Alessandro



On Fri, Jun 21, 2019 at 8:50 AM Scooter Willis <will...@gmail.com> wrote:
Wanted to revisit the socket problem. As a fun project wanted to port Minecraft which can be run locally but requires a login process to play the game locally. 

Have you considered https://developer.mozilla.org/en-US/docs/Web/API/WebSocket  as a way to implement socket connections?

On Wednesday, July 11, 2018 at 7:57:07 PM UTC-4, Scooter Willis wrote:
That fixed the problem. 

Found a lightweight REST api package with JSON support written to run on android. http://hgoebl.github.io/DavidWebb/ and it is working as well. 

It would be great if REST Jax-RS Jersey 2.5 framework worked which allows you leverage Netbeans and other IDE to generate interfaces from entity classes etc. I opened a bug report that the cherrpj compiler crashes on many of the jar files when generating the javascript library. The negative is lots and lots of JAR files that aren't needed so adds a considerable amount of code to be downloaded.

Very excited about the potential. 

On Wednesday, July 11, 2018 at 2:39:28 AM UTC-4, Alessandro Pignotti wrote:
Hello,

Browsers do not allow arbitrary connections to TCP/UDP ports, that's why you got SocketExceptions while trying to use RMI. To support HTTP connections, CheerpJ provides an XHR based HTTP/HTTPS handler. This handler is enable by default when converting an applet, for application it needs to be manually enabled by running

cjCall("java.lang.System", "setProperty", "java.protocol.handler.pkgs", "com.leaningtech.handlers");

after cheerpjInit() and before cheerpjRunMain/cheerpjRunJar

Regards,
Alessandro
On Sun, Jul 8, 2018 at 8:43 PM, Scooter Willis <will...@gmail.com> wrote:
Based on testing and reporting/confirmation from cheerpj Java RMI doesn't work because javascript doesn't allow socket connections. RMI and any applications that depend on socket connections should probably be listed as not supported in Cheerpj. 

Now looking to do communication/posting of data to web server via REST where most of the frameworks that will do the heavy lifting for you have numerous dependencies on third party JAR libraries in particular http libraries which are required for authentication. The concern is the dependency on third-party JAR files that use low-level socket library or http interfaces that won't map well onto javascript libraries. Tyring to avoid doing a deep dive of the various frameworks to get lucky and find one that works. 

Can you provide any guidance/recommendation on a particular REST framework that will work in a cheerpj client? 

Any experience with SOAP/WSDL working in Cheerpj?

Going to assume JDBC related code would not work because of the need for a socket connection. 

Having Java applications that run in a web browser is fairly limiting if you can't do real-time data transaction to a web server. 


--
You received this message because you are subscribed to the Google Groups "CheerpJ Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cheerpj-develop...@googlegroups.com.
To post to this group, send email to cheerpj-d...@googlegroups.com.


--

Leaning Technologies Limited

Alessandro Pignotti
CTO
aless...@leaningtech.com

Leaning Technologies Limited 
www.leaningtech.com

Twitter  Facebook  LinkedIn 

--
You received this message because you are subscribed to the Google Groups "CheerpJ Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cheerpj-develop...@googlegroups.com.
To post to this group, send email to cheerpj-d...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Scooter Willis

unread,
Jun 21, 2019, 6:10:53 AM6/21/19
to Alessandro Pignotti, CheerpJ Developers
I think the original Minecraft was pure Java but does use http://lwjgl.org/. Maybe possible to port to WebGL which is used in onshape.com and very solid. Since Microsoft bought it a few years ago for a billion+ they have released a new version which is a rewrite and designed to run on Windows. The Java version the source is not available and my understanding strong effort to obfuscate the code. Very large plugin community with amazing mods etc that keep the original Java version live and well. The original Java version was designed to be extended.

Let me know when you have a socket version to test and if any interest in http://lwjgl.org/

Thanks

Scooter

Alessandro Pignotti

unread,
Jun 21, 2019, 6:13:58 AM6/21/19
to CheerpJ Developers, Scooter Willis
It could be possible to port LWJGL to WebGL, but it would be a significant project. It is not something that we have the resources to do internally but you are welcome to try it. It could be convenient to start from simple LWJGL demos instead of the full Minecraft package.

Alessandro
Reply all
Reply to author
Forward
0 new messages