remove rejected messages from queue

This commit is contained in:
cidoku 2025-02-15 14:48:59 -03:00
parent 5891b70035
commit bcd81e8bd9

View File

@ -1750,11 +1750,9 @@ class gui(QtGui.QWidget):
msg += "%" msg += "%"
# Avoid duplicate messages self.msgqueueList.addItem(self.icchatinput.text())
if self.lastmsg != msg: self.msgqueue.append(msg)
self.msgqueueList.addItem(self.icchatinput.text()) self.lastmsg = msg
self.msgqueue.append(msg)
self.lastmsg = msg
self.icchatinput.clear() self.icchatinput.clear()
self.realizationbtn.setPressed(False) self.realizationbtn.setPressed(False)
@ -1834,7 +1832,7 @@ class gui(QtGui.QWidget):
if self.msgqueue: if self.msgqueue:
chatmsgcomp = (self.msgqueue[0].split('#')[5]).replace('<dollar>', '$').replace('<percent>', '%').replace('<and>', '&').replace('<num>', '#') chatmsgcomp = (self.msgqueue[0].split('#')[5]).replace('<dollar>', '$').replace('<percent>', '%').replace('<and>', '&').replace('<num>', '#')
if (chatmsgcomp == '>' or chatmsgcomp == '<') or (f_char_id == self.mychar and self.m_chatmessage[CHATMSG] == chatmsgcomp): # our message showed up if (f_char_id == self.mychar and self.m_chatmessage[CHATMSG] == chatmsgcomp): # our message showed up
del self.msgqueue[0] del self.msgqueue[0]
self.msgqueueList.takeItem(0) self.msgqueueList.takeItem(0)
if self.additivebtn.isChecked(): if self.additivebtn.isChecked():
@ -3028,12 +3026,17 @@ class TCP_Thread(QtCore.QThread):
error, total = self.parent.tcp.recv() error, total = self.parent.tcp.recv()
if error == -2: if error == -2:
# if the message can't be sent, discard it
if sendtick == 4:
print '[warning] The server rejected the message'
del self.parent.msgqueue[0]
self.parent.msgqueueList.takeItem(0)
continue continue
elif error == -1: elif error == -1:
self.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'critical', 'Connection lost', "%s connection to server lost." % ("WebSocket" if self.parent.tcp.isWS else "TCP")) self.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'critical', 'Connection lost', "%s connection to server lost." % ("WebSocket" if self.parent.tcp.isWS else "TCP"))
self.parent.willDisconnect = True self.parent.willDisconnect = True
self.quit() self.quit()
return return
for network in total: for network in total:
header = network[0] header = network[0]