71 |
71 |
72 if self.__multiplex: |
72 if self.__multiplex: |
73 if not connection.waitForReadyRead(3000): |
73 if not connection.waitForReadyRead(3000): |
74 return |
74 return |
75 idString = bytes(connection.readLine()).decode( |
75 idString = bytes(connection.readLine()).decode( |
76 "utf-8", 'backslashreplace') |
76 "utf-8", 'backslashreplace').strip() |
77 if idString in self.__connections: |
77 if idString in self.__connections: |
78 self.__connections[id].close() |
78 self.__connections[idString].close() |
79 self.__connections[id] = connection |
79 self.__connections[idString] = connection |
80 else: |
80 else: |
81 idString = "" |
81 idString = "" |
82 if self.__connection is not None: |
82 if self.__connection is not None: |
83 self.__connection.close() |
83 self.__connection.close() |
84 |
84 |
104 else: |
104 else: |
105 if self.__connection is not None: |
105 if self.__connection is not None: |
106 self.__connection.close() |
106 self.__connection.close() |
107 |
107 |
108 self.__connection = None |
108 self.__connection = None |
|
109 |
|
110 def connectionNames(self): |
|
111 """ |
|
112 Public method to get the list of active connection names. |
|
113 |
|
114 If this is not a multiplexing server, an empty list is returned. |
|
115 |
|
116 @return list of active connection names |
|
117 @rtype list of str |
|
118 """ |
|
119 return list(self.__connections.keys()) |
109 |
120 |
110 @pyqtSlot() |
121 @pyqtSlot() |
111 def __receiveJson(self, idString): |
122 def __receiveJson(self, idString): |
112 """ |
123 """ |
113 Private slot handling received data from the client. |
124 Private slot handling received data from the client. |
196 return False |
207 return False |
197 |
208 |
198 proc = QProcess() |
209 proc = QProcess() |
199 proc.setProcessChannelMode(QProcess.ForwardedChannels) |
210 proc.setProcessChannelMode(QProcess.ForwardedChannels) |
200 args = [clientScript, self.__hostAddress, str(self.serverPort())] |
211 args = [clientScript, self.__hostAddress, str(self.serverPort())] |
|
212 if idString: |
|
213 args.append(idString) |
201 args.extend(clientArgs) |
214 args.extend(clientArgs) |
202 proc.start(interpreter, args) |
215 proc.start(interpreter, args) |
203 if not proc.waitForStarted(10000): |
216 if not proc.waitForStarted(10000): |
204 proc = None |
217 proc = None |
205 |
218 |