package server.commands.methods;
import java.io.IOException;
import java.util.Iterator;
import org.quickserver.net.server.ClientHandler;
import server.protocol.GameRoom;
import server.protocol.Message;
/**
* The Class SendMessage. Handles the message sending.
*/
public class SendMessage {
/**
* Sends the message.
*
* @param handler the handler
* @param room the room
* @param message the message
* @throws IOException Signals that an I/O exception has occurred.
*/
public void send(ClientHandler handler, GameRoom room, String message)
throws IOException {
Iterator<ClientHandler> iterator = room.getClients().iterator();
ClientHandler toHandler = null;
while (iterator.hasNext()) {
toHandler = (ClientHandler) iterator.next();
toHandler.getObjectOutputStream().reset();
toHandler.sendClientObject(new Message(message));
}
}
}