Cooperation/CooperationClient.py

changeset 164
b395b006d2a8
parent 162
28f235c426c4
child 165
3302a726fd1e
equal deleted inserted replaced
163:8f0630371845 164:b395b006d2a8
168 self.__server.serverPort()) 168 self.__server.serverPort())
169 169
170 connection.error.connect(self.__connectionError) 170 connection.error.connect(self.__connectionError)
171 connection.disconnected.connect(self.__disconnected) 171 connection.disconnected.connect(self.__disconnected)
172 connection.readyForUse.connect(self.__readyForUse) 172 connection.readyForUse.connect(self.__readyForUse)
173 connection.rejected.connect(self.__connectionRejected)
174
175 def __connectionRejected(self, msg):
176 """
177 Private slot to handle the rejection of a connection.
178
179 @param msg error message (string)
180 """
181 self.connectionError.emit(msg)
173 182
174 def __connectionError(self, socketError): 183 def __connectionError(self, socketError):
175 """ 184 """
176 Private slot to handle a connection error. 185 Private slot to handle a connection error.
177 186
178 @param socketError reference to the error object (QAbstractSocket.SocketError) 187 @param socketError reference to the error object (QAbstractSocket.SocketError)
179 """ 188 """
180 connection = self.sender() 189 connection = self.sender()
181 if socketError != QAbstractSocket.RemoteHostClosedError: 190 if socketError != QAbstractSocket.RemoteHostClosedError:
182 if connection.peerPort() != 0: 191 if connection.peerPort() != 0:
183 msg = "{0}:{1}\n{2}\n".format( 192 msg = "* {0}:{1}\n{2}\n".format(
184 connection.peerAddress().toString(), 193 connection.peerAddress().toString(),
185 connection.peerPort(), 194 connection.peerPort(),
186 connection.errorString() 195 connection.errorString()
187 ) 196 )
188 else: 197 else:
189 msg = "{0}\n".format(connection.errorString()) 198 msg = "* {0}\n".format(connection.errorString())
190 self.connectionError.emit(msg) 199 self.connectionError.emit(msg)
191 if connection == self.__initialConnection: 200 if connection == self.__initialConnection:
192 self.cannotConnect.emit() 201 self.cannotConnect.emit()
193 self.__removeConnection(connection) 202 self.__removeConnection(connection)
194 203

eric ide

mercurial