From 8731c6903026cab0a69cf54592ac2778cb575043 Mon Sep 17 00:00:00 2001 From: jamesbunton Date: Tue, 2 May 2006 14:19:35 +0000 Subject: [PATCH] Data received after the connection has been cleaned up is now ignored (instead of throwing an exception) Clean up properly when a switchboard dies (fixes exception if somebody logs on, an avatar retrieval starts, and then they log off before it finishes.) git-svn-id: http://delx.cjb.net/svn/pymsnt/trunk@152 55fbd22a-6204-0410-b2f0-b6c764c7e90a committer: jamesbunton --- src/tlib/msn/msn.py | 6 ++++-- src/tlib/msn/msnw.py | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tlib/msn/msn.py b/src/tlib/msn/msn.py index 1ad7cfd..373c551 100644 --- a/src/tlib/msn/msn.py +++ b/src/tlib/msn/msn.py @@ -786,11 +786,12 @@ class MSNEventBase(LineReceiver): raise NotImplementedError def sendLine(self, line): - if LINEDEBUG: log.msg(">> " + line) + if LINEDEBUG: log.msg("<< " + line) LineReceiver.sendLine(self, line) def lineReceived(self, line): - if LINEDEBUG: log.msg("<< " + line) + if LINEDEBUG: log.msg(">> " + line) + if not self.connected: return if self.currentMessage: self.currentMessage.readPos += len(line+"\r\n") try: @@ -827,6 +828,7 @@ class MSNEventBase(LineReceiver): self.handle_UNKNOWN(cmd, params.split(' ')) def rawDataReceived(self, data): + if not self.connected: return extra = "" self.currentMessage.readPos += len(data) diff = self.currentMessage.readPos - self.currentMessage.length diff --git a/src/tlib/msn/msnw.py b/src/tlib/msn/msnw.py index b9e3028..2241c22 100644 --- a/src/tlib/msn/msnw.py +++ b/src/tlib/msn/msnw.py @@ -375,7 +375,6 @@ class NotificationClient(msn.NotificationClient): msn.NotificationClient.logOut(self) def connectionLost(self, reason): - print "NotificationClient.connectionLost!!!" if not self.factory.msncon: return # If we called logOut def wait(): LogEvent(INFO, self.factory.msncon.ident) @@ -465,6 +464,11 @@ class SwitchboardSessionBase(msn.SwitchboardClient): LogEvent(INFO, self.ident) del self.msncon self.transport.disconnect() + + def connectionLost(self, reason): + self.msncon = None + self.msnobj = None + self.ident = (self.ident[0], self.ident[1] + " Disconnected!") def loggedIn(self): LogEvent(INFO, self.ident) -- 2.39.2