Temple of The Roguelike Forums

Development => Programming => Topic started by: wire_hall_medic on September 27, 2012, 03:23:10 PM

Title: Cookie I/O
Post by: wire_hall_medic on September 27, 2012, 03:23:10 PM
Hey all,

So I'm in the planning stages of my next project, and I'd like to do it as an applet (I'm a Java programmer).  My reasoning is that it would make updating very easy, and I'd be able to make it accessible to mobile devices while still allowing keyboard input (I'm thinking a button bar on the side; phones are TERRIBLE interfaces for games).

However, I'd like to be able to suspend the game.  In QuickHack (http://roguebasin.roguelikedevelopment.org/index.php/QuickHack (http://roguebasin.roguelikedevelopment.org/index.php/QuickHack)), I saved high scores and save files by using text files with a checksum, which was a clean, simple way for me to do things.  I'd like to use cookies to do the same.

Sadly, I've had some trouble finding a decent rundown on how to read and write cookies.  Maybe I just missed a tutorial on the Oracle site.  If any one has any tips, links to tutorials, etc, I'd greatly appreciate it!
Title: Re: Cookie I/O
Post by: Leaf on September 27, 2012, 08:41:59 PM
http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/accessingCookies.html

You have to sign your jar for that to work, though, and it may require that the applet be deployed via JNLP rather than the usual applet tags (but I am not sure!).  AFAIK, if you want to access cookies with an unsigned applet, you have to use some JSObject hackery (which will also require you to set "mayscript" in the document where you deploy your applet), which makes it seem a little dumb to not be able to access cookies with an unsigned applet! D:
Title: Re: Cookie I/O
Post by: Robobot on September 27, 2012, 11:40:34 PM
So I'm in the planning stages of my next project, and I'd like to do it as an applet (I'm a Java programmer).  My reasoning is that it would make updating very easy, and I'd be able to make it accessible to mobile devices while still allowing keyboard input (I'm thinking a button bar on the side; phones are TERRIBLE interfaces for games).

Sorry, but which mobile devices support Java-Applets? I don't' know any.
Title: Re: Cookie I/O
Post by: Leaf on September 28, 2012, 02:10:22 AM
You might be able to compile it all to JavaScript with GWT or something.
Title: Re: Cookie I/O
Post by: wire_hall_medic on September 28, 2012, 05:20:41 PM
@Robobot: Dag nabbit, I think you're right.  Hmm, not sure if it's worth the extra effort, then.
Title: Re: Cookie I/O
Post by: Robobot on September 28, 2012, 08:51:17 PM
@Robobot: Dag nabbit, I think you're right.  Hmm, not sure if it's worth the extra effort, then.

If you want to code in Java and for the web, Leaf's suggestion of GWT sounds like a good approach. I never used it, but heard a lot of good things about it. You might want to use localStorage instead of cookies though.