diff options
author | engn33r <engn33r@users.noreply.github.com> | 2021-04-26 22:20:26 -0400 |
---|---|---|
committer | engn33r <engn33r@users.noreply.github.com> | 2021-04-26 22:20:26 -0400 |
commit | cefb07e88302970b134f85142aeec485451ff8e7 (patch) | |
tree | ddb51ac3982912cade269fcfedbfd8645e0eabaa | |
parent | 83edf1b78655ad2a4330777170a1c0bf2070f106 (diff) | |
download | websocket-client-cefb07e88302970b134f85142aeec485451ff8e7.tar.gz |
Add ping_payload to run_forever()
-rw-r--r-- | websocket/_app.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/websocket/_app.py b/websocket/_app.py index 8a6c8f5..babea1d 100644 --- a/websocket/_app.py +++ b/websocket/_app.py @@ -190,18 +190,19 @@ class WebSocketApp(object): self.sock.close(**kwargs) self.sock = None - def _send_ping(self, interval, event): + def _send_ping(self, interval, event, payload): while not event.wait(interval): self.last_ping_tm = time.time() if self.sock: try: - self.sock.ping() + self.sock.ping(payload) except Exception as ex: _logging.warning("send_ping routine terminated: {}".format(ex)) break def run_forever(self, sockopt=None, sslopt=None, ping_interval=0, ping_timeout=None, + ping_payload="", http_proxy_host=None, http_proxy_port=None, http_no_proxy=None, http_proxy_auth=None, skip_utf8_validation=False, @@ -226,6 +227,8 @@ class WebSocketApp(object): if set to 0, not send automatically. ping_timeout: int or float timeout (in seconds) if the pong message is not received. + ping_payload: str + payload message to send with each ping. http_proxy_host: <type> http proxy host name. http_proxy_port: <type> @@ -304,7 +307,7 @@ class WebSocketApp(object): if ping_interval: event = threading.Event() thread = threading.Thread( - target=self._send_ping, args=(ping_interval, event)) + target=self._send_ping, args=(ping_interval, event, ping_payload)) thread.daemon = True thread.start() |