#940: Fix message encoding.

remotes/github/python3
Ramón M. Gómez 2020-07-08 11:47:53 +02:00
parent b21ea0708b
commit 64c933fbb8
2 changed files with 3 additions and 6 deletions

View File

@ -132,17 +132,14 @@ class MessagesProcessor(QtCore.QThread):
msg_id, data = msg
logger.debug('Got Message on User Space: {}:{}'.format(msg_id, data))
if msg_id == ipc.MSG_MESSAGE:
module, message, data = data.split('\0')
module, message, data = data.decode('utf-8').split('\0')
self.message.emit((module, message, data))
elif msg_id == ipc.MSG_LOGOFF:
self.logoff.emit()
elif msg_id == ipc.MSG_SCRIPT:
self.script.emit(data.decode('utf-8'))
except Exception as e:
try:
logger.error('Got error on IPC thread {}'.format(utils.exceptionToMessage(e)))
except:
logger.error('Got error on IPC thread (an unicode error??)')
if self.ipc.running is False and self.running is True:
logger.warn('Lost connection with Service, closing program')

View File

@ -182,7 +182,7 @@ class ClientProcessor(threading.Thread):
try:
m = msg[1] if msg[1] is not None else b''
l = len(m)
data = MAGIC + bytes(msg[0]) + bytes(l & 0xFF) + bytes(l >> 8) + m
data = MAGIC + bytes([msg[0]]) + bytes([l & 0xFF]) + bytes([l >> 8]) + m
try:
self.clientSocket.sendall(data)
except socket.error as e: