I did not know what to call this question however i have this chat program where i create several chat persons from the ChatPerson object.
Now whenever a client connects a new ChatPerson is created. But i ran into a problem on the client side. The client side has to know whom are sending for example chat messages.
Therefore my question to you is how do i solve this puzzle? do i extend the object and create an object that is “Me” or do i just make another instance of the object and that is the one passed on through out the program?
What is the best pratice?
It’s hard to tell what you want or are asking. It seems you need to identify clients.
Give the ChatPerson class an id field – perhaps use the nickname of the user.
Each message should carry the id of the client sending the msg. The chat server should control registration of clients to ensure ids are unique.