Send the data frame. >>> ws = create_connection("ws://echo.websocket.events") >>> frame = ABNF.create_frame("Hello", ABNF.OPCODE_TEXT) >>> ws.send_frame(frame) >>> cont_frame = ABNF.create_frame("My name is ", ABNF.OPCODE_CONT, 0) >>> ws.send_frame(f
(self, frame)
| 316 | return self.send(data, ABNF.OPCODE_BINARY) |
| 317 | |
| 318 | def send_frame(self, frame) -> int: |
| 319 | """ |
| 320 | Send the data frame. |
| 321 | |
| 322 | >>> ws = create_connection("ws://echo.websocket.events") |
| 323 | >>> frame = ABNF.create_frame("Hello", ABNF.OPCODE_TEXT) |
| 324 | >>> ws.send_frame(frame) |
| 325 | >>> cont_frame = ABNF.create_frame("My name is ", ABNF.OPCODE_CONT, 0) |
| 326 | >>> ws.send_frame(frame) |
| 327 | >>> cont_frame = ABNF.create_frame("Foo Bar", ABNF.OPCODE_CONT, 1) |
| 328 | >>> ws.send_frame(frame) |
| 329 | |
| 330 | Parameters |
| 331 | ---------- |
| 332 | frame: ABNF frame |
| 333 | frame data created by ABNF.create_frame |
| 334 | """ |
| 335 | if self.get_mask_key: |
| 336 | frame.get_mask_key = self.get_mask_key |
| 337 | data = frame.format() |
| 338 | length = len(data) |
| 339 | if isEnabledForTrace(): |
| 340 | trace(f"++Sent raw: {repr(data)}") |
| 341 | trace(f"++Sent decoded: {frame.__str__()}") |
| 342 | with self.lock: |
| 343 | while data: |
| 344 | bytes_sent = self._send(data) |
| 345 | data = data[bytes_sent:] |
| 346 | |
| 347 | return length |
| 348 | |
| 349 | def send_binary(self, payload: bytes) -> int: |
| 350 | """ |