Hy .I have a client server app .the server listens on some port and for each client generates a thread that manages it.this is based on sockets and is similar to this but the client conects when the Swing interface starts, it calls a method from time to time that sends inf to the server and on close , it closes the stream and socket.The server thread stays awake until the client socket leaves ,and listens to requests.
What i am trying to do is .When a client does something from the interface(pushes a button), to notify all the other clients and i`m stuck.how do i do that.I have to do this by using observer pattern, and i have no idea to use it in this context.how do i notify all the treads an how will they notify the other clients ?
Any sugestion egen though is not about the observer pattern are well received.Thanx
Instead of notifying a thread (which is not simple to do and not needed IMHO), you should have an object on the server which represents each client (if you don’t already). Keep a collection of these. When a client needs to notify all the other clients it can call a method on each of the other objects representing the clients. This can be done using the Observer pattern.