import java.io.*; class ITypeThread extends Thread { Peer parent; BufferedReader stdIn; String fromServer; String fromUser; StringBuffer outString; StringBuffer inString; boolean keepGoing = true; int inChar, outChar; public ITypeThread(Peer p) { super("ITypeThread"); parent = p; stdIn = new BufferedReader(new InputStreamReader(System.in)); outString = new StringBuffer(); inString = new StringBuffer(); } public void run() { try { while(keepGoing) { // check for input from user while(stdIn.ready()) { outChar = stdIn.read(); if(outChar != '\n') outString.append((char)outChar); else { System.out.println("contents of outString: " + outString.toString()); parseInput(outString.toString()); outString.delete(0, outString.length()); } } yield(); } stdIn.close(); } catch(IOException e) { } } public void parseInput(String s) { if(s.startsWith(":")) { // command parent.command(s.substring(1)); } else { // message parent.bcastString(s, "Peer Client"); } } }