103 def __handleDisconnect(self): |
103 def __handleDisconnect(self): |
104 """ |
104 """ |
105 Private slot handling a disconnect of the writer. |
105 Private slot handling a disconnect of the writer. |
106 """ |
106 """ |
107 if self.__connection is not None: |
107 if self.__connection is not None: |
|
108 self.__receiveJson() # read all buffered data first |
108 self.__connection.close() |
109 self.__connection.close() |
109 |
110 |
110 self.__connection = None |
111 self.__connection = None |
111 |
112 |
112 @pyqtSlot() |
113 @pyqtSlot() |
113 def __receiveJson(self): |
114 def __receiveJson(self): |
114 """ |
115 """ |
115 Private slot handling received data from the writer. |
116 Private slot handling received data from the writer. |
116 """ |
117 """ |
117 connection = self.__connection |
118 while self.__connection and self.__connection.canReadLine(): |
118 |
119 dataStr = self.__connection.readLine() |
119 while connection and connection.canReadLine(): |
|
120 dataStr = connection.readLine() |
|
121 jsonLine = bytes(dataStr).decode("utf-8", 'backslashreplace') |
120 jsonLine = bytes(dataStr).decode("utf-8", 'backslashreplace') |
122 |
121 |
123 #- print("JSON Reader ({0}): {1}".format(self.__name, jsonLine)) |
122 #- print("JSON Reader ({0}): {1}".format(self.__name, jsonLine)) |
124 #- this is for debugging only |
123 #- this is for debugging only |
125 |
124 |