Copyright (c) 1998 Massachusetts Institute of Technology * * @see cs101.net.Client * * @author Todd C. Parnell, tparnell@ai.mit.edu * @author Lynn Andrea Stein, las@ai.mit.edu * @version $Id: DefaultReadLoop.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $ */ public class DefaultReadLoop implements Runnable { /** Communicates with the network. */ protected Client client; /** Animates this object.*/ protected Thread spirit; /** * A generic read loop for client. * * @see cs101.net.Client */ public DefaultReadLoop ( Client c ) { this.client = c; this.spirit = new Thread (this); this.spirit.start(); } /** * Called by this object's thread. Shouldn't be called otherwise. */ public void run () { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.println(">>"); System.out.flush(); try { this.client.send( in.readLine() ); } catch (IOException e) {} } } } /* * $Log: DefaultReadLoop.java,v $ * Revision 1.1.1.1 2002/06/05 21:56:32 root * CS101 comes to Olin finally. * * Revision 1.5 1998/07/24 17:13:39 tparnell * Placate new javadoc behavior * * Revision 1.4 1998/07/22 18:17:54 tparnell * move from util to net * * Revision 1.3 1998/06/03 21:56:46 tparnell * minor bugfix * * Revision 1.2 1998/06/03 19:28:16 tparnell * update from Java 1.0 to 1.1. * * Revision 1.1 1998/03/13 22:18:11 tparnell * Import from server crash. I think the src and class files match up. * */