an rmi client server design problem

I am implementng a networked cards game in java using rmi . The server keeps track of the turn of the players and activates ther clients(on an applet) whose turn it is to play .

Both client and server call each others methods.

Prblem one :

Right now if a a client disconnects , a process run through all the clients active and gets a remote exception on the server and removes ALL the 4 players i nthat particulat group. If I want to save the state and allow any player to contuniue from there , how will I do it?

Problem 2:

How do I keep track of the time a client takes to play.

If he takes longer than say 5 mintes , I should disconnect him.

[702 byte] By [sseans] at [2007-9-26 7:30:46]
# 1
please give me ideas!!
sseans at 2007-7-1 17:28:10 > top of Java-index,Core,Core APIs...
# 2

There seem to be two issues at stake: <b>catching the remote exception</b> and <b>multithreading</b> your application on the server.

When a client disconnects "suddenly" (without logging off via remote method call to alert server), the remote method call by the server to all <i>n</i> players triggers a remote exception that must be caught and dealt with accordingly (do I understand that it is causing the application to exit at present?) When caught, you must identify which player is "gone" and remove that client from the pool of client objects.

Right now, it sounds as if the app is NOT multithreaded. You can create a low-priority thread that looks at a time variable for each player to determine its last moment of play. This means every successful remote call from client-server or vice-versa will update that client's 'lastplayed' variable with (long) System.currentTimeMillis() for example.

kenmcneill at 2007-7-1 17:28:10 > top of Java-index,Core,Core APIs...
# 3

you are absolutely right in everything.

when the player disconnects "suddenly" all the people playingwith him are also thrown out by the server.

The application is not mulithreaded . What will I ahve to do if I have to allow the game to contnue if a player disconencts by allowing another player to log on in the disconnected players place.It means I have to store the game state smewehre? cos an exception may or may not always lead to a stable state.

by mulitthreding what do you mean? a thread handling each player? I am goingto make a message que( a thread for each player) which will be fed the messages fro mthe server (corresponding to each players needs)and continue at its own speed.

sseans at 2007-7-1 17:28:10 > top of Java-index,Core,Core APIs...