def return_data_to_clients(self, client_id, data): try: for client_socket in self.clients: return_data_string = 'Client {} sent: {}'.format(client_id, data) data_byte_array =QByteArray() stream =QDataStream(data_byte_array, QIODevice.WriteOnly) stream.setVersion(QDataStream.Qt_5_9) stream.writeUInt32(0) stream.writeQString(return_data_string) client_socket.write(data_byte_array) except Exception as e: print(e)
def write_data(self): try: data_byte_array = QByteArray() stream = QDataStream(data_byte_array, QIODevice.WriteOnly) stream.setVersion(QDataStream.Qt_5_9) stream.writeUInt32(0) if self.line_edit: print('inside write_data') stream.writeQString(self.line_edit.text()) self.socket.write(data_byte_array) data_byte_array = None if self.line_edit: self.line_edit.setText('') except Exception as e: print(e)