Send JSON data using a bytes-returning encoder as a binary frame. Use this when your JSON encoder (like orjson) returns bytes instead of str, avoiding the encode/decode overhead.
(
self,
data: Any,
compress: int | None = None,
*,
dumps: JSONBytesEncoder,
)
| 496 | await self.send_str(dumps(data), compress=compress) |
| 497 | |
| 498 | async def send_json_bytes( |
| 499 | self, |
| 500 | data: Any, |
| 501 | compress: int | None = None, |
| 502 | *, |
| 503 | dumps: JSONBytesEncoder, |
| 504 | ) -> None: |
| 505 | """Send JSON data using a bytes-returning encoder as a binary frame. |
| 506 | |
| 507 | Use this when your JSON encoder (like orjson) returns bytes |
| 508 | instead of str, avoiding the encode/decode overhead. |
| 509 | """ |
| 510 | await self.send_bytes(dumps(data), compress=compress) |
| 511 | |
| 512 | async def write_eof(self) -> None: # type: ignore[override] |
| 513 | if self._eof_sent: |