views:

66

answers:

1

Hi!

i am trying to create framework/library /API for creating small multiuser games, in which the goal is to achieve 'decoupling' between the server, client and business logic.

The server in my case is kind of registering the clients and sent that list to business logic, clients are registering with the server, and the business logic do the game logic stuff and updates the client by getting the list of client from server.

But currently, i have only one class, so its trivial but this could consist of several game objects (and what would be the role of classes serialized/remote like the game engine, player, score, move, board). i decided to use the RMI for this and this will definitely use callback mechanism can somebody told me.

How could i achieve this encorporating all the requirement of server updating clients (callbacks).

PS:i m currently working on the design, which has one remote/serialized object for handling gamelogic but i wanted to use other classes as i mentioned for sake of making multiuser game library and to show the use of important classes in it as an example.

thanks a lot

jibby

+2  A: 

If you are intending this framework to work for real time games then I would advise against using RMI - it isn't really designed for that sort of thing. Also be aware that two-way RMI between machines on different subnets is very hard to get working.

It seems as if you need the clients to be informed by the server when events occur. When your client connects it can lookup a Remote object from the server's RMI registry and call a method on that to pass a Remote object it has created (hosted on the client) to the server. The server will have to maintain a collection of these client objects and iterate through them to send events. This is a tricky architecture to get right as if the network goes down or a client goes offline you will have to deal with all sorts of nasty error handling and freeze ups. I would recommend you keep the majority of communication in one direction - from client to server. Also keep it as simple as possible - simply a Remote object on the server with various methods that take Serializables as parameters and return Serializables.

Whether or not this is MVC depends on your interpretation. You could see the clients as views with the model and controller on the server in which case it is MVC with the event mechanism being a remote implementation of the observer pattern.

The trickiest part of the task will definitely be getting the code on the server that notifies the clients correct as it will need to be multi-threaded and handle errors gracefully - good luck!

Russ Hayward
i was already considering some of issue u shared and will consider others also, thanks
Static Void Main