/** * SendingThread.java */ package boondock.holdem.Network; import java.io.*; import java.net.*; /** * SendingThread sends a message to the server in another Thread. * * @author Jonathan O'Keefe * @author Scott Semonian * @author Matt Brinza * @author Hamid R. Tahsildoost * * @author The Boondock Saints * @author No Limit Texas Holdem */ public class SendingThread extends Thread { private Socket clientSocket; private String messageToSend; /** * SendingThread constructor. * * @param socket The socket. * @param userName The name of the user sending the message. * @param message The message that the sender is sending. */ public SendingThread( Socket socket, String userName, String message ) { super( "SendingThread: " + socket ); clientSocket = socket; messageToSend = userName + constants.MESSAGE_SEPARATOR + message; } /** * Send message and exit the Thread. */ public synchronized void run() { try { PrintWriter writer = new PrintWriter( clientSocket.getOutputStream() ); writer.println( messageToSend ); writer.flush(); } catch ( IOException ioException ) { System.out.println("IO Exception Occured while running SendingThread"); //ioException.printStackTrace(); } } } // end class SendingThread class