|
From: Felix B. <bf...@gm...> - 2003-05-09 18:25:03
|
Hi,
the following problem can occur:
XNap's joscar plugin receives an incoming IncomingMessage__4_7 for which it
doesn't have a ChatChannel yet, so it creates one and adds the message to the
channel to display it. Now it can happen that the first message is displayed
twice, that's because of the following code:
private void notifyIncomingMessage(OscarConnection connection) {
IncomingMessageEvent e = new IncomingMessageEvent(this);
for (int i = 0; i < connection.getOscarListeners().size(); i++) {
OscarListener l = (OscarListener) connection.getOscarListeners().
elementAt(i);
l.onIncomingMessage(e);
}
XNap's new Channel object calls:
oscar_connection.addOscarListener(this);
in order to be notified of future chat messages. But since it's added to the
listener vector in OscarConnection it sometimes gets the message twice.
I'd recommend to change the code above to:
private void notifyIncomingMessage(OscarConnection connection) {
IncomingMessageEvent e = new IncomingMessageEvent(this);
Object[] array = connection.getOscarListeners().toArray();
for (int i = 0; i < array.length; i++) {
((OscarListener)array[i]).onIncomingMessage(e);
}
}
Thus we don't run into any concurrent modifications and ensure each listener
gets the message exactly once. This should be done for all listener events.
The method connectToServer() doesn't have any effect. As far as I could see as
soon as you instantiate a new OscarConnection it connects to the server. If
you call a
connection.getClient().disconnect();
it's properly disconnect, but a
connection.getClient().connectToServer();
doesn't work since it simply calls a thread.start(). But a thread that's
already dead can't be restarted again in java, you have to create a new
thread and start that one.
Sincerely,
Felix
P.S.: An xnap3 release is planned at the end of next week it'd be great if you
could fix the jar location problem, the other stuff is not so important.
--
Use Debian GNU/Linux!
http://www.felix.beldesign.de
|