D
DaveL
Hi, I'm a 2nd year undergrad with a personal project on my agenda.
The project I've been working on is a ChatApplication under the
Client/Server Architecture, which is still in its early stages. I will
do my best to explain my current problem.
As a user for most ChatApplications, such as MSN, ICQ,
YahooMessenger...
A conversation is usually started by either initiating a "Conversation
Window" from the "Contact List GUI", or if incoming messages from other
users are detected. Regardless of how a conversation is started, once
it has been started, a Thread that listens for the incoming messages
from your conversation partner is usually required for a responsive
GUI. Here's a very simple example of a Thread I wrote.
-------------------------------------------------------------------------------
1 private class IncomingListener extends Thread {
2 public IncomingListener() {
3 start();
4 }
5
6 public void run() {
7 String msg = theObjChat.readLine();
8 displayArea.append(msg);
9 }
10 }
-------------------------------------------------------------------------------
My problem is, since read methods (such as read( ) or readLine( ) )
BLOCKS until input is available, when I want to close the conversation
window between me and my partner, the Thread which should always listen
for incoming messages won't be cleaned up (terminated). Since the
Thread will keep hanging on line7 becuase readLine( ) blocks.
My knowledge in the java network i/o is very entry level, if any
solution or advice could be offered, it would be kindly appreaciated.
Thank you very much for taking the time to read through.
Regards,
Dave L.
The project I've been working on is a ChatApplication under the
Client/Server Architecture, which is still in its early stages. I will
do my best to explain my current problem.
As a user for most ChatApplications, such as MSN, ICQ,
YahooMessenger...
A conversation is usually started by either initiating a "Conversation
Window" from the "Contact List GUI", or if incoming messages from other
users are detected. Regardless of how a conversation is started, once
it has been started, a Thread that listens for the incoming messages
from your conversation partner is usually required for a responsive
GUI. Here's a very simple example of a Thread I wrote.
-------------------------------------------------------------------------------
1 private class IncomingListener extends Thread {
2 public IncomingListener() {
3 start();
4 }
5
6 public void run() {
7 String msg = theObjChat.readLine();
8 displayArea.append(msg);
9 }
10 }
-------------------------------------------------------------------------------
My problem is, since read methods (such as read( ) or readLine( ) )
BLOCKS until input is available, when I want to close the conversation
window between me and my partner, the Thread which should always listen
for incoming messages won't be cleaned up (terminated). Since the
Thread will keep hanging on line7 becuase readLine( ) blocks.
My knowledge in the java network i/o is very entry level, if any
solution or advice could be offered, it would be kindly appreaciated.
Thank you very much for taking the time to read through.
Regards,
Dave L.