Receive string data(byte array) from the server. Returns ---------- data: string (byte array) value.
(self)
| 384 | self.send(payload, ABNF.OPCODE_PONG) |
| 385 | |
| 386 | def recv(self) -> Union[str, bytes]: |
| 387 | """ |
| 388 | Receive string data(byte array) from the server. |
| 389 | |
| 390 | Returns |
| 391 | ---------- |
| 392 | data: string (byte array) value. |
| 393 | """ |
| 394 | with self.readlock: |
| 395 | opcode, data = self.recv_data() |
| 396 | if opcode == ABNF.OPCODE_TEXT: |
| 397 | data_received: Union[bytes, str] = data |
| 398 | if isinstance(data_received, bytes): |
| 399 | return data_received.decode("utf-8") |
| 400 | elif isinstance(data_received, str): |
| 401 | return data_received |
| 402 | elif opcode == ABNF.OPCODE_BINARY: |
| 403 | data_binary: bytes = data |
| 404 | return data_binary |
| 405 | else: |
| 406 | return "" |
| 407 | |
| 408 | def recv_data(self, control_frame: bool = False) -> tuple: |
| 409 | """ |