RMI and JME?

Lately I was thinking a bit and thought of the technique RMI. RMI is a way to remotely access methods, thus the code can be stored on a server and you only would need a client that knows which functions it can call.



I continued the thinking process and wondered what use RMI could have within a game, for instance made with JME. Would RMI actually allow the engine and game to be stored on the server, thus only distributing a client with the art/sounds/music? I assume games would get unplayable because the bandwidth would be to poor. So now im wondering, what use could RMI have in JME? or any multiuser based game? Which parts would benefit of RMI?



The main idea behind this is that there can never be an hacked client.  Sure they can hack the "stubbed"-client but then they'd only see which functions get called and which parameters get passed, it would still be a blackbox.



Wonder what your views are! :slight_smile:

Well, RMI is a hideous beast in my opinion…I used to have to use it all the time.  Sure it’s gotten better per release of the JDK, but still not something I’d touch if I didn’t have to (and I don’t anymore).  RMI is not really designed for the kind of performance most games need.  You could probably get it to work well for a chess game maybe? :wink:



I designed JGN with a similar concept, but instead of method invocation it’s a messaging architecture where you communicate via Message objects and add listeners to those messages that are received.  You can get a blackbox effect with JGN and I’d highly recommend the performance of it above RMI. :wink:



…I am biased as it’s my system though. :wink:



http://captiveimagination.com/svn/public/jgn/trunk

darkfrog said:

Well, RMI is a hideous beast in my opinion....I used to have to use it all the time.  Sure it's gotten better per release of the JDK, but still not something I'd touch if I didn't have to (and I don't anymore).  RMI is not really designed for the kind of performance most games need.  You could probably get it to work well for a chess game maybe? ;)

I designed JGN with a similar concept, but instead of method invocation it's a messaging architecture where you communicate via Message objects and add listeners to those messages that are received.  You can get a blackbox effect with JGN and I'd highly recommend the performance of it above RMI. ;)

....I am biased as it's my system though. ;)

http://captiveimagination.com/svn/public/jgn/trunk


You always find a way to promote your package, dont you!  :lol:

What im looking for.. is a solution that keeps as much of the source-code/game a secret(read: on the server) but still allow to play a game for instance written in JmonkeyEngine... not sure if RMI is the right approach. The "Remote" part had drawn my attention

Well, if you're really sold on RMI you can still use JGN. :slight_smile:



I have a system called RemoteObject that allows you to pass an interface on one client along with the name and remote client and it connects to the remote client (granted that it has an object registered with the same name) and you can simply invoke methods on the interface and they will be remotely invoked and their return objects will come across to you.  All the benefits of RMI (and then some) without the evils.  :wink:



Also, there's SharedObject support so you can register an object on one machine and share it with other people connected to you and any time anyone makes a change to that object it gets synchronized across all clients sharing it. :slight_smile:



I've got a ton of other really awesome things if you people would just look at the frickin' API.  :stuck_out_tongue:

Now im envisioning you as a frontdoor-salesman trying to sell his product, at all costs  :lol:



What I actually wanted to know… and this probably isnt the right section of the forum anymore… is…

what use would a RMI-type of approach have in a game made in jme?



Say you want to make an MMORPG in jme. Its a prime example of Client-server… what kind of stuff would you want to handle RMI-wise (using your Networks Librairy or the Java RMI one)?



If any at all…  :?

In an MMORPG game I might (not that I've done any of this  ) have a special server designed for transactions and keeping them synchronized (we know MMO's are notorious for being hacked or exploited) and making RMI calls (of some sort) to make final "requests" for say an "exchange", "trade", "purchase", or anything else that needs to be protected from being spoofed.  This way you are making a specific method call on a specific server that is in charge of making sure that transaction is thread-safe, synchronized, and properly executed.  This is a good way to avoid exploits like cloning.

So basically the only things you want to remotely invocate are the functions that are mission-critical to the succes of your game/app? Primairilly transactions, in your example?

Yes, then I "might" use SharedObjects to synchronize public state information about the player to other players in range, then use synchronization information for long-lived objects, vector events for short-lived objects.

Well, I have to say i do agree with frog that RMI is seldom appropriate for games.



The biggest issue is that RMi is synchronous.  This means an RMi call has to block on the caller side until the call gets to the server, the server executes the call, and the answer returns to the client.



Most games really don't want to do these things in multiple threads, and cant afford to block the game thread that long.



I'm less in love with the "distributed object" approach that frog likes.  It begs the issue of synchronization.  yes,  a change on one object is reflected on its "partners" in other processes/machines, but not right away. There is osme period of time wen the machines are out of synch.  This is true in any net communications, but to my mind distributed obejcts hide this and in fact make it harder to deal with.  It gets even worse if your communicating the object updates discretely with an order-ungauranteed communication protocol like UDP.





Races and breaks in referential integrity are, IMO, really, really easy to create in this sort of system and just what you don't want  in a game.  (Breaks in RI lead directly to "dupe bugs" among other things.)

You should really give JGN a try. It is indeed very good.