]> code.delx.au - pymsnt/blobdiff - src/tlib/msn/msnw.py
Fixed tests to work with rev152+ fix.
[pymsnt] / src / tlib / msn / msnw.py
index 2241c22aab20b3c885233d305f26a95e7d0e04e0..7355d32c1159ec3657fb989b3fbf3361b8b81e49 100644 (file)
@@ -360,6 +360,10 @@ class DispatchClient(msn.DispatchClient):
 
 
 class NotificationClient(msn.NotificationClient):
+       def doDisconnect(self):
+               if hasattr(self, "transport") and self.transport:
+                       self.transport.loseConnection()
+
        def loginFailure(self, message):
                self.factory.msncon.loginFailed(message)
        
@@ -373,9 +377,13 @@ class NotificationClient(msn.NotificationClient):
        
        def logOut(self):
                msn.NotificationClient.logOut(self)
+               # If we explicitly log out, then all of these events
+               # are now redundant
+               self.loginFailure = self.doDisconnect
+               self.loggedIn = self.doDisconnect
+               self.connectionLost = self.doDisconnect
        
        def connectionLost(self, reason):
-               if not self.factory.msncon: return # If we called logOut
                def wait():
                        LogEvent(INFO, self.factory.msncon.ident)
                        msn.NotificationClient.connectionLost(self, reason)
@@ -461,11 +469,13 @@ class SwitchboardSessionBase(msn.SwitchboardClient):
                self.ready = False
 
        def __del__(self):
+               self.ready = False
                LogEvent(INFO, self.ident)
                del self.msncon
                self.transport.disconnect()
        
        def connectionLost(self, reason):
+               self.ready = False
                self.msncon = None
                self.msnobj = None
                self.ident = (self.ident[0], self.ident[1] + " Disconnected!")