I am having a big problem in planning out my design of a similation i want to make.
The big problem is that my design would make server and client communicate by writing strings to each other, thus making synchronization of information(such as updating player information...) impossible...
in other words... Here is my design
Server -- a main component that waits for clients to connect and creates a socket that is passed to a thread that handles the client
this thread does this:
wait for message
this thread is also passed an arraylist pointer that all the threads share(to be able to communicate to each other):
PrintWriter i = new PrintWriter(ArrayList.get(x).sock.getOutputStream);
There is no way I can think of that allows a client(a panel that has a socket connected to port 1234)
Please tell me a method I can make this work...
In a JFrame, to make a client you need to have a button that sends information from a textfield to the server(easy)...
and a listener that listens if there are any messages for the client.
Where should this listener be positioned, is it a thread, and how should it look like?
Thanks ahead of time