Optionally suppress the client's "pong" response.
(ws)
| 870 | |
| 871 | @staticmethod |
| 872 | def install_hook(ws): |
| 873 | """Optionally suppress the client's "pong" response.""" |
| 874 | |
| 875 | ws.drop_pongs = False |
| 876 | ws.pongs_received = 0 |
| 877 | |
| 878 | def wrapper(fcn): |
| 879 | def _inner(opcode: int, data: bytes): |
| 880 | if opcode == 0xA: # NOTE: 0x9=ping, 0xA=pong |
| 881 | ws.pongs_received += 1 |
| 882 | if ws.drop_pongs: |
| 883 | # prevent pong responses |
| 884 | return |
| 885 | # leave all other responses unchanged |
| 886 | return fcn(opcode, data) |
| 887 | |
| 888 | return _inner |
| 889 | |
| 890 | ws.protocol._handle_message = wrapper(ws.protocol._handle_message) |
| 891 | |
| 892 | @gen_test |
| 893 | def test_client_ping_timeout(self): |
no test coverage detected