[vlma-devel] commit: Handle "nickname already in use" errors. (Adrien Grand )
git version control
git at videolan.org
Tue Jun 17 20:06:07 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Tue Jun 17 19:32:19 2008 +0200| [538289d72079414cc3b3a7c21a2533d015721b75]
Handle "nickname already in use" errors.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=538289d72079414cc3b3a7c21a2533d015721b75
---
.../org/videolan/vlma/notifier/IRCNotifier.java | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/notifier/IRCNotifier.java b/vlma-core/src/main/java/org/videolan/vlma/notifier/IRCNotifier.java
index 2f4a1d8..a781f48 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/notifier/IRCNotifier.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/notifier/IRCNotifier.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import org.apache.log4j.Logger;
import org.schwering.irc.lib.IRCConnection;
+import org.schwering.irc.lib.IRCConstants;
import org.schwering.irc.lib.IRCEventListener;
import org.schwering.irc.lib.IRCModeParser;
import org.schwering.irc.lib.IRCUser;
@@ -129,6 +130,16 @@ public class IRCNotifier extends Notifier {
public void onError(int code, String error) {
logger.error("IRC notifier encountered an error: " + error);
+ if (code == IRCConstants.ERR_NICKNAMEINUSE) {
+ // Reconnect with another nickname
+ nick = nick + "_";
+ conn.doNick(nick);
+ try {
+ conn.connect();
+ } catch (IOException e) {
+ logger.error("Cannot connect to the IRC server", e);
+ }
+ }
}
public void onInvite(String chan, IRCUser user, String nick) { }
More information about the vlma-devel
mailing list