This content has been marked as final. Show 3 replies
In the server you should implement a thread to serve incoming messagges. Messages received should be pushed in a queue shared by thread so must be synchronized. Another thread spools this queue and send messages into sockets connected with clients.
Note that the client's serving threads is also your clients list.
If you want to dispatch messages to some client without boadcasting to all you can push message in the queue adding information of clients to be dispatched (a single user or a group).
thanks topfoxy for the reply, I've managed to send msgs to everyone and private... but used a different method i think.. basically on each connection it would add the sockets to a vector list adn the same with usernames. and to send to everyone on the server the thread will just loop all the socket vector sending it to each user.. on private it will use the uservector to get the index of the user name and then using that index to get hte socket and hten sending it to that socket only... :)... what do you think? good or bad?