jdmonin / JSettlers2

Java Settlers project home, downloads, and GPLv3 source code. To download the latest version as a JAR, see https://github.com/jdmonin/JSettlers2/releases/latest .
http://nand.net/jsettlers/
GNU General Public License v3.0
157 stars 63 forks source link

JSettlers Web Applet #17

Closed ghost closed 7 years ago

ghost commented 9 years ago

I would really like to run JSettlers on my web server so some of my friends can play without having to install java. In the README it references some files that i can not find in the web directory. Are they missing? Or am i missing something. If this is something on my part please let me know and point me in the right direction. Oh yeah, someone on the sourceforge forums for JSettlers posted the same question about a month ago.

jdmonin commented 9 years ago

Hi Caleb,

I'm very sorry about the delay getting back to you on this. Thanks for pointing this out, it's been a while since that part of the README was updated.

One thing about JSettlers is that everyone will still need to install java to run it, there isn't an html5 or android client.

I added the missing files (index.html, account.html) to the src/web/ directory, for now you can get them from https://github.com/jdmonin/JSettlers2/tree/master/src/web .

For the README update, does this sound clearer?

To provide a web page from which users can run the applet, you will need to set up an http server such as Apache. We assume you have installed it already, and will refer to "${docroot}" as a directory to place files to be served by your web server.

Copy index.html from src/web/ to ${docroot}. If you're going to use an accounts database and anyone can register their own account (this is not the default setting), also copy accounts.html.

Edit the html to make sure the PORT parameter in "index.html" and "account.html" applet tags match the port of your JSettlers server, and the text starting "this applet connects to" has the right server name and port for users who can't run the applet in their browser. If you're using account.html, also un-comment index.html's link to account.html.

Next copy the JSettlers.jar client file to ${docroot}. This will allow users to use the web browser plug-in or download it to connect from their computer. If you've downloaded it as JSettlers-{version}-full.jar, rename it to JSettlers.jar.

Your web server directory structure should now contain: ${docroot}/index.html ${docroot}/account.html (optional) ${docroot}/JSettlers.jar

Users should now be able to visit your web site to run the JSettlers client.

Thanks again. Please let me know if this helps.

ghost commented 9 years ago

No worries... Thank you for taking the time to fix this and reply... I will put this to use tomorrow... Very impressed at what you have done with this project. You have my full support.

Sincerely, Caleb

ghost commented 9 years ago

I followed the updated README and got everything working to a point, whenever I visit the website http://54.175.129.20/ I am presented an error: "Could not connect to the server: java.security.AcessControlException: access denied ("java.net.SocketPermission...") I get the same error when visiting nand.com/jsettlers/. However i can still play a practice game. Any suggestions?

Sincerely, Caleb Beckstein

jdmonin commented 9 years ago

Hi Caleb,

Thanks for trying it out.

I think part of what you're seeing is that the applet security model only allows an applet to connect to the server that hosts it. The jsettlers applet from http://54.175.129.20/ can only connect to a server at that IP, I think the applet parameters are pointing at another IP right now which the java plug-in usually won't allow for applets.

I'm looking into why you get that error at nand.net, where the website and jsettlers server are both hosted on the same site.

Thanks, -Jeremy

jdmonin commented 7 years ago

If anyone else runs into this, the most effective workaround is to download JSettlers.jar from the page with the applet and run that local copy, which isn't subject to the applet's network limitations.

When you launch the jar it will ask what server and port to connect to. This will be the same server as the applet webpage URL, and the port can be found in the applet tag source if it's not the default port.

The long-term fix for the applet is to convert it to use JNLP instead, and/or sign the JAR with a certificate as required by newer JREs.