diff --git a/enconnect/mattermost/client.py b/enconnect/mattermost/client.py index 0758109..899da8f 100644 --- a/enconnect/mattermost/client.py +++ b/enconnect/mattermost/client.py @@ -15,6 +15,7 @@ from typing import Optional from typing import TYPE_CHECKING +from encommon.times import Timer from encommon.types import DictStrAny from encommon.types import NCNone from encommon.types import sort_dict @@ -36,6 +37,12 @@ +PING = { + 'action': 'ping', + 'seq': 1} + + + class Client: """ Establish and maintain connection with the chat service. @@ -210,6 +217,10 @@ def __operate( assert socket is not None + timer = Timer( + 30, start='min') + + self.__identify() @@ -221,6 +232,13 @@ def __operate( if receive is not None: self.__event(receive) + if timer.pause(): + continue # NOCVR + + logger(item='ping') + + self.socket_send(PING) + logger(item='close')