I am developing a bingo game in java. The scenario is such that the client is generating the numbers on the bingo cards. Now i allow 4 users at a time to play this game. I also want my client to see the other 3 cards of the other users. In trying this, whenever my client is loaded i create a serializable object DataAcross with string username and an int numbers that can store my username a 24 values. On connecting to the server, i send my data through the ObjectOutputStream to the server. The process is simple, all the four cards send in their values to the server when they connect to the server and then expect back the entire 4 cards information (username and their corresponding array back). Now what is happening here is that say i as client1 connect first, the problem is that i send my data and am expecting back the data for all the four players, but the other players have not yet connected to the client. So i do not get all the 4 values back. Instead i get only my information back and thus my client goes into an exception since it was expected to get all the values and is getting back only 1. Now I have tried making the client sleep for 60 seconds before it can take back the data, so that i buy time for all the clients to log in and send the data so that after 60 seconds i can get back all the data. But it is not working. The client that logs in the last (also the current thread in client) gets all the values, whereas the clients that have logged in previously do not get any values. Is it because the server cannot keep a track of the previous threads of clients..and thus the final thread is the only thread that must be receiving the data.....or is it some other reason. I think if there is a means to keep these spawned threads in some form of a vector or something i should be able to send the values to all the clients. Either ways i would like you to help me in it.
i hope this helps