Send a `Ping frame`_. .. _Ping frame: https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.2 Parameters: data: payload containing arbitrary binary data.
(self, data: BytesLike)
| 398 | self.state = CLOSING |
| 399 | |
| 400 | def send_ping(self, data: BytesLike) -> None: |
| 401 | """ |
| 402 | Send a `Ping frame`_. |
| 403 | |
| 404 | .. _Ping frame: |
| 405 | https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.2 |
| 406 | |
| 407 | Parameters: |
| 408 | data: payload containing arbitrary binary data. |
| 409 | |
| 410 | """ |
| 411 | # RFC 6455 allows control frames after starting the closing handshake. |
| 412 | if self._state is not OPEN and self._state is not CLOSING: |
| 413 | raise InvalidState(f"connection is {self.state.name.lower()}") |
| 414 | self.send_frame(Frame(OP_PING, data)) |
| 415 | |
| 416 | def send_pong(self, data: BytesLike) -> None: |
| 417 | """ |