I have a UDP server and need to perform an "all" function. That means when a user sends "all blah blah" the server checks a list of clients and sends "blah blah" to all of them.
I've stored the clients in a HashMap and I'm trying to figure a way to iterate through, create a packet and send for each record.
The record would look like key:name value ip,port. I know this isn't an ideal way to do it, but I've spent a week or so on this and just kept making things more and more complicated.
private void sendToAll(InetAddress clientIP, int clientPort, String message, String fromUserName) {
for (Object key : cHASH.keySet())
{
Object value = cHASH.get(key);
//System.out.print(value);
//split value
//clientIP = [0]
//clientPort = [1]
//serverResponse(clientIP,ClientPort);
}
}
Clearly the trouble is actually coding it and I just can't seem to get it. I have the serverResponse code, which is just a method that takes the inetAddress, Port and some other objects to make and send the packets.
Any help with this is appreciated.