We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Applet + Remote Server (RMI, xmlrpclib, ...)
Page Index Toggle Pages: 1
Applet + Remote Server (RMI, xmlrpclib, ...) (Read 1122 times)
Applet + Remote Server (RMI, xmlrpclib, ...)
Aug 8th, 2008, 11:34am
 
Hi everyone.

We've been searching for solution to make an applet access mysql while the applet is hosted on a different server.

All solutions we found didn't allowed access to a remote server unless you sign your applet. Which we found pretty ugly and not user-friendly.
solutions we tried:

Mysql library: http://www.bezier.de/mysql/
DatainputStream and PHP: http://www.devdaily.com/java/edu/pj/pj010023/index.shtml
LoadString() and PHP : http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1133759630

Then we found RMI, Remote Method Invocation, ( ohhhhhh ) and managed to make it work only locally for the moment as we are not really sure how to integrate that to our sketch and or even how to make it work has an applet. Here is the example we tried: http://www.devdaily.com/java/edu/pj/pj010023/index.shtml and here are some info on RMI http://java.sun.com/products/rmi-iiop/
Did anyone tried it and know if we are going to have the same security issues?

And now that we know about RMI, we found this library that was just under our nose: The xmlrpclib library ( http://plw.media.mit.edu/people/arikan/xmlrpclib/ ) seems to be doing the same thing as RMI ( RPC ). Again, did anyone tried it and know if we are going to have the same security issues?

This all because we are doing a game that might be host on different servers. We have a database on our server and we want people to be able to save score but we also want to get some data to measure how long people play, how many life left, etc... All sort of thing that could help us adjust the difficulty and game-play.

Some feedback would be great as I think we might not be the only one with this problem.

ps: Does anyone know why flash and Java have those security problem and not php?
Re: exchange with Remote Server (RMI, xmlrpclib, .
Reply #1 - Aug 8th, 2008, 12:21pm
 
Doesn't work over the net. We start to think that the security thing is build in the java plugin. And that ANY communications with remote server are forbidden.

WHYYYYYYYYYYYYYY!!!!
Re: Applet + Remote Server (RMI, xmlrpclib, ...)
Reply #2 - Aug 8th, 2008, 1:16pm
 
Correct, for safety an applet can only make net connections back to the server from where it was served. IT has to be that way to be "safe". Otherwise you could be opening yourself up to having stuff spied on, or personal data sent to 3rd party sites without you knowing etc.

One possibility is if the applet is on A, then you need some PHP on A that talks to the MySQL on B. You can't have the PHP on B.. unless it's the PHP on A that talks to PHP on B.
Re: Applet + Remote Server (RMI, xmlrpclib, ...)
Reply #3 - Aug 8th, 2008, 3:37pm
 
Yes that's a solution. But game website might not want us to give them a php file with the game.

We finally decided to only give a "demo" version of the game to game-website that would have a link to our website.
And keep the game hosted on our server. We have enough people coming here anyway, and our game will probably be lost in the amount of war games, etc... as ours is a HIV/AIDS educational Game.

Thanks for you reply, I still don't get why php doesn't have the security thing as you can also access everything on a computer with it.
Re: Applet + Remote Server (RMI, xmlrpclib, ...)
Reply #4 - Aug 9th, 2008, 2:09pm
 
PHP doesn't have the same restrictions, as it runs on the server, not on the visitor's computer, so there's not the same "trust" issues.
Re: Applet + Remote Server (RMI, xmlrpclib, ...)
Reply #5 - Aug 9th, 2008, 3:30pm
 
That's true, it's different.
Thank you for answering my questions Smiley
Re: Applet + Remote Server (RMI, xmlrpclib, ...)
Reply #6 - Sep 18th, 2008, 1:45am
 
my question is a little lowlevel. I can´t understand how we send data to the php. I mean, the first example just have a string with the url, but is there something i can do to send something like a "println"?
thanks!
Re: Applet + Remote Server (RMI, xmlrpclib, ...)
Reply #7 - Sep 18th, 2008, 10:47am
 
You can send data in the URL as a GET request easily e.g. open("http://www.foo.com/bar.php?a="+a+"&u="+u);

You can't however interactively talk to PHP, i.e. get some data, send a string, get more, etc, each message is separate, and has to be done independently.
Re: Applet + Remote Server (RMI, xmlrpclib, ...)
Reply #8 - Sep 18th, 2008, 11:15am
 
John was quicker to reply. :0

Basically , how our php programmer quickly explained it to me:

You make a request to a php file with all the things you want the php to know. You use loadString as a trick. You request a file or data that will be generated by the php file. The php file can either send something back or not send anything.

For example, you want to send the size and x position of a rect to a php file called myRequest.php.

If you are not expecting a response you write/send once:   Quote:
loadString("http://www.mydomain.com/myRequest.php?&size="+ rectSize +"&x="+ rectX);



if you are expecting a responce you write/send once:
Quote:
String[] getData;
getData = loadString("http://www.mydomain.com/myRequest.php?&size="+ rectSize +"&x="+ rectX);


Just like if you were opening a txt file from the internet ( see loadString in reference ).

variable rectSize is equal to the size of your rect and variable  rectX is equal to the rect x position.
size and x will be understand as variable by the php file.

Then you do the rest is in the php which is another problem, but I am sure you can find how to use the received data and send back somethings.

That system works pretty well and is really quick, But like John said you have to send the request every-time you want the php to know that your variables have been updated. Also remember that the php file and your applet have to be on the same server, because of security reasons.

Hope that helps

Page Index Toggle Pages: 1