MCPcopy Index your code
hub / github.com/websocket-client/websocket-client / recv

Method recv

websocket/_core.py:386–406  ·  view source on GitHub ↗

Receive string data(byte array) from the server. Returns ---------- data: string (byte array) value.

(self)

Source from the content-addressed store, hash-verified

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 """

Callers 15

__iter__Method · 0.95
__next__Method · 0.95
test_proxy_connectMethod · 0.95
test_recvMethod · 0.95
test_recv_timeoutMethod · 0.95
test_closeMethod · 0.95
_recvFunction · 0.45
recvFunction · 0.45

Calls 1

recv_dataMethod · 0.95