Send a `Binary frame`_. .. _Binary frame: https://datatracker.ietf.org/doc/html/rfc6455#section-5.6 Parameters: data: payload containing arbitrary binary data. fin: FIN bit; set it to :obj:`False` if this is the first frame of
(self, data: BytesLike, fin: bool = True)
| 339 | self.send_frame(Frame(OP_TEXT, data, fin)) |
| 340 | |
| 341 | def send_binary(self, data: BytesLike, fin: bool = True) -> None: |
| 342 | """ |
| 343 | Send a `Binary frame`_. |
| 344 | |
| 345 | .. _Binary frame: |
| 346 | https://datatracker.ietf.org/doc/html/rfc6455#section-5.6 |
| 347 | |
| 348 | Parameters: |
| 349 | data: payload containing arbitrary binary data. |
| 350 | fin: FIN bit; set it to :obj:`False` if this is the first frame of |
| 351 | a fragmented message. |
| 352 | |
| 353 | Raises: |
| 354 | ProtocolError: If a fragmented message is in progress. |
| 355 | |
| 356 | """ |
| 357 | if self.expect_continuation_frame: |
| 358 | raise ProtocolError("expected a continuation frame") |
| 359 | if self._state is not OPEN: |
| 360 | raise InvalidState(f"connection is {self.state.name.lower()}") |
| 361 | self.expect_continuation_frame = not fin |
| 362 | self.send_frame(Frame(OP_BINARY, data, fin)) |
| 363 | |
| 364 | def send_close(self, code: CloseCode | int | None = None, reason: str = "") -> None: |
| 365 | """ |