public class ChatClient extends Thread {
protected ObjectInputStream iObjStrem;
protected ObjectOutputStream oObjStream;
protected ChatFrame frame ;
protected Socket server ;
public ChatClient (String title, Socket s)
throws IOException {
super(title) ;
server = s ;
frame = newFrame(title, this);
}
protected ChatFrame newFrame(String title, ChatClient cc) {
return new ChatFrame(title,cc) ;
}
//LA LINEA 34 è oObjStream.writeObject( s );
public void SendString( String s ) throws IOException {
oObjStream.writeObject( s ) ;
}
public void run () {
try {
iObjStrem = new ObjectInputStream(server.getInputStream());
oObjStream = new ObjectOutputStream(server.getOutputStream());
frame.show ();
while (true) {
String line = (String)iObjStrem.readObject();
frame.AddText(line);
}
} catch (Exception ex) {
ex.printStackTrace ();
} finally {
try {
server.close ();
System.out.println( "Connessione col server persa, disconnesso..." ) ;
frame.dispose() ;
System.exit(1);
} catch (IOException ex) {
ex.printStackTrace ();
}
}
}