Send close data to the server. Parameters ---------- status: int Status code to send. See STATUS_XXX. reason: str or bytes The reason to close. This must be string or UTF-8 bytes.
(self, status: int = STATUS_NORMAL, reason: bytes = b"")
| 485 | return self.frame_buffer.recv_frame() |
| 486 | |
| 487 | def send_close(self, status: int = STATUS_NORMAL, reason: bytes = b""): |
| 488 | """ |
| 489 | Send close data to the server. |
| 490 | |
| 491 | Parameters |
| 492 | ---------- |
| 493 | status: int |
| 494 | Status code to send. See STATUS_XXX. |
| 495 | reason: str or bytes |
| 496 | The reason to close. This must be string or UTF-8 bytes. |
| 497 | """ |
| 498 | if status < 0 or status >= ABNF.LENGTH_16: |
| 499 | raise ValueError("code is invalid range") |
| 500 | self.connected = False |
| 501 | self.send(struct.pack("!H", status) + reason, ABNF.OPCODE_CLOSE) |
| 502 | |
| 503 | def close(self, status: int = STATUS_NORMAL, reason: bytes = b"", timeout: int = 3): |
| 504 | """ |
no test coverage detected