Cooperation/Connection.py

changeset 164
b395b006d2a8
parent 162
28f235c426c4
child 165
3302a726fd1e
diff -r 8f0630371845 -r b395b006d2a8 Cooperation/Connection.py
--- a/Cooperation/Connection.py	Wed Mar 31 12:03:43 2010 +0000
+++ b/Cooperation/Connection.py	Wed Mar 31 12:52:59 2010 +0000
@@ -56,6 +56,7 @@
     getParticipants = pyqtSignal()
     participants    = pyqtSignal(list)
     editorCommand   = pyqtSignal(str, str, str)
+    rejected        = pyqtSignal(str)
     
     def __init__(self, parent = None):
         """
@@ -79,7 +80,7 @@
         self.__buffer = QByteArray()
         
         self.readyRead.connect(self.__processReadyRead)
-        self.disconnected.connect(self.__pingTimer.stop)
+        self.disconnected.connect(self.__disconnected)
         self.__pingTimer.timeout.connect(self.__sendPing)
         self.connected.connect(self.__sendGreetingMessage)
     
@@ -394,3 +395,12 @@
         data = QByteArray("{0}{1}{2}{1}".format(
             Connection.ProtocolEditor, SeparatorToken, msg.size())) + msg
         self.write(data)
+    
+    def __disconnected(self):
+        """
+        Private slot to handle the connection being dropped.
+        """
+        self.__pingTimer.stop()
+        if self.__state == Connection.WaitingForGreeting:
+            self.rejected.emit(self.trUtf8("* Connection to {0}:{1} refused.").format(
+                self.peerName(), self.peerPort()))

eric ide

mercurial