try{
is = new DataInputStream(new BufferedInputStream(s.getInputStream()));
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String inputLine = new String();
int port;
String msgid = new String();
String message = new String();
int offset;
//int blank = 32;
System.out.println("ListenThread - we are listening to " + String.valueOf(t.portnum));
while ((inputLine = br.readLine()) != null && !inputLine.startsWith("Bye ")) {
offset = inputLine.indexOf(' ");
//System.out.println("LT-" + String.valueOf(t.portnum) + " Received:" + inputLine);
if (offset > 0) {
msgid = inputLine.substring(0,offset);
//System.out.println("LT smsg msgid:" + msgid);
message = inputLine.substring(offset+1); //don't store the space
smsg = new ServerMessage(t.portnum,msgid,message);
System.out.println("ListenThread smsg " + String.valueOf(t.portnum) +" msgid:" +
smsg.msgid + "msg:" + smsg.msg);
t.addMsg(smsg);
//synchronized (t) {
// t.msgque.addElement(smsg);
// t.notify();
//}
}
else
System.out.println("ListenThread read weird line" );
}
is.close();
}
catch (IOException e) {
System.out.println("ListenThread " + t.portnum + e );
//e.printStackTrace();
}
catch (Exception e) {
System.out.println("ListenThread " + t.portnum + e );
e.printStackTrace();
}
System.out.println("ListenThread " + t.portnum + "going byebye" );
smsg = new ServerMessage(t.portnum,"dead","");
t.addMsg(smsg);
//synchronized (t) {
// t.msgque.addElement(smsg);
// t.notify();
//}