Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI and Observable  RSS feed

 
Arthur Noseda
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I am trying to build a Game class that would extend both Remote and Observable. I have already these separately, but here I feel very uneasy, for I don't know which way to program is the best. As you can see my purpose is not very clear, so what I really need is somebody to help me fix things. Thanks.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arthur -
I've been through this myself, and have developed it both ways. The most efficient way is, alas, not the simplest. It requires that you develop both Observer and Observable as remote entities.
In this model, you need to register the Observer (your game client) as an "interested listener" in what the Observable (your game server, I'm guessing) is doing. Your Observable implementation needs to notify/update interested Observers according to state changes that they're interested in.
It's easiest on the client if the server is Remote, so it can find the service through a lookup mechanism. It's easiest on the server if it can post its updates locally to what ultimately are remote stubs of the clients.
So you end up exporting both! It works very well. If you're skeptical about how well known this approach is, you can look at remote event handling in Jini, or Java Messaging Service, or really every major distributed event service out there today.
 
Arthur Noseda
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. It seems that I'm going to have a lot of work on my way to make my beautiful game available, but with such an explanation, I can not fail, right ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!