Send a Pong_. .. _Pong: https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.3 An unsolicited pong may serve as a unidirectional heartbeat. Args: data: Payload of the pong. A :class:`str` will be encoded to UTF-8. Raises: Conn
(self, data: DataLike = b"")
| 716 | return pong_received |
| 717 | |
| 718 | async def pong(self, data: DataLike = b"") -> None: |
| 719 | """ |
| 720 | Send a Pong_. |
| 721 | |
| 722 | .. _Pong: https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.3 |
| 723 | |
| 724 | An unsolicited pong may serve as a unidirectional heartbeat. |
| 725 | |
| 726 | Args: |
| 727 | data: Payload of the pong. A :class:`str` will be encoded to UTF-8. |
| 728 | |
| 729 | Raises: |
| 730 | ConnectionClosed: When the connection is closed. |
| 731 | |
| 732 | """ |
| 733 | if isinstance(data, BytesLike): |
| 734 | data = bytes(data) |
| 735 | elif isinstance(data, str): |
| 736 | data = data.encode() |
| 737 | else: |
| 738 | raise TypeError("data must be str or bytes-like") |
| 739 | |
| 740 | async with self.send_context(): |
| 741 | self.protocol.send_pong(data) |
| 742 | |
| 743 | # Private methods |
| 744 |
nothing calls this directly
no test coverage detected