import java.rmi.RemoteException;

/**
 * Java Chat - A simple chatroom application - MessageTransaction Class.
 *
 * This is the MessageTransaction class. It allows a message to be sent
 * using a separate thread, freeing up the rest of the program. 
 *
 * @author Sean Handley
 * @version November, 2006
 */
public class MessageTransaction implements Runnable {

    private IChatServer serverObject;
    private String msg;

    /**
     * Constructor for the message transaction.
     * 
     * @param serverObject
     * @param msg
     */
    public MessageTransaction(IChatServer serverObject, String msg)
    {
        this.serverObject = serverObject;
        this.msg = msg;
    }
    /**
     * Sends the message as a new thread.
     */
    public void run() {
        try
        {
            serverObject.sendMessage(msg);
        }
        catch(RemoteException e)
        {
            System.err.println(e.toString());
        }
    }

}