Ensure messages are sent in order, one at a time
This commit is contained in:
parent
d08f43e6be
commit
a15e2a5c9d
|
@ -13,7 +13,7 @@ from PyQt5.QtCore import (
|
||||||
import nio
|
import nio
|
||||||
|
|
||||||
from .network_manager import NetworkManager
|
from .network_manager import NetworkManager
|
||||||
from .pyqt_future import futurize
|
from .pyqt_future import PyQtFuture, futurize
|
||||||
|
|
||||||
|
|
||||||
class Client(QObject):
|
class Client(QObject):
|
||||||
|
@ -234,7 +234,7 @@ class Client(QObject):
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def sendMarkdown(self, room_id: str, text: str) -> None:
|
def sendMarkdown(self, room_id: str, text: str) -> PyQtFuture:
|
||||||
html = self.manager.backend.htmlFilter.fromMarkdown(text)
|
html = self.manager.backend.htmlFilter.fromMarkdown(text)
|
||||||
content = {
|
content = {
|
||||||
"body": text,
|
"body": text,
|
||||||
|
@ -247,8 +247,12 @@ class Client(QObject):
|
||||||
# If the thread pool workers are all occupied, and @futurize
|
# If the thread pool workers are all occupied, and @futurize
|
||||||
# wrapped sendMarkdown, the messageAboutToBeSent signal neccessary
|
# wrapped sendMarkdown, the messageAboutToBeSent signal neccessary
|
||||||
# for local echoes would not be sent until a thread is free.
|
# for local echoes would not be sent until a thread is free.
|
||||||
@futurize(max_running=1)
|
#
|
||||||
def send(self):
|
# send() only takes the room_id argument explicitely because
|
||||||
|
# of consider_args=True: This means the max number of messages being
|
||||||
|
# sent at a time is one per room at a time.
|
||||||
|
@futurize(max_running=1, consider_args=True)
|
||||||
|
def send(self, room_id: str) -> PyQtFuture:
|
||||||
return self.net.talk(
|
return self.net.talk(
|
||||||
self.nio.room_send,
|
self.nio.room_send,
|
||||||
room_id = room_id,
|
room_id = room_id,
|
||||||
|
@ -256,7 +260,7 @@ class Client(QObject):
|
||||||
content = content,
|
content = content,
|
||||||
)
|
)
|
||||||
|
|
||||||
return send(self)
|
return send(self, room_id)
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(str, result="QVariant")
|
@pyqtSlot(str, result="QVariant")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user