problem: I have no idea how to get around this problem...
while(true) {
/*chat section begin*/ if (newMessage) { //if a newMessage flag is set
System.out.println("new Message set " +id); //print the id of computer receiving and that it entered if, serverside
os.println(cMessage); //output the message to printwriter,clientside
newMessage=false; //set the newMessage flag to false
os.flush(); //flush printwriter
}
/*chat section end*/
System.out.println("outside the chat loop"); //outside of the above if statment
String inLine=is.readLine(); /*At this point all function stops and it may not receive any messages... i have no idea how to fix this*/
System.out.println(inLine); //print message serverside
if (inLine.length()>0) //checks if the client input is of decent length
outLine = processInput(inLine); //sends input to method that returns the server responses
else
outLine=processInput(""); //if the inLine was crappy, send blank line back (later change to "invalid")
os.println(outLine); //print to printwriter
os.flush(); //flush
//old chat section position
if(outLine.equals("/close")) //if the server output is close, break connection
break; //breaking
}
//clean up
os.close();
is.close();
client.close();
}
full code and tMessage source is located at:
http://www.angelfire.com/alt/grosslax/snet.java
http://www.angelfire.com/alt/grosslax/tMessage.java
I realize that this code is also very rustic and not the best way of doing things, any help to superior ideas would be appreciated