Package server.commands.methods

Source Code of server.commands.methods.SendMessage

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));
    }
  }
}
TOP

Related Classes of server.commands.methods.SendMessage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.