MCPcopy Index your code
hub / github.com/python-websockets/websockets / send_text

Method send_text

src/websockets/protocol.py:318–339  ·  view source on GitHub ↗

Send a `Text frame`_. .. _Text frame: https://datatracker.ietf.org/doc/html/rfc6455#section-5.6 Parameters: data: payload containing text encoded with UTF-8. fin: FIN bit; set it to :obj:`False` if this is the first frame of

(self, data: BytesLike, fin: bool = True)

Source from the content-addressed store, hash-verified

316 self.send_frame(Frame(OP_CONT, data, fin))
317
318 def send_text(self, data: BytesLike, fin: bool = True) -> None:
319 """
320 Send a `Text frame`_.
321
322 .. _Text frame:
323 https://datatracker.ietf.org/doc/html/rfc6455#section-5.6
324
325 Parameters:
326 data: payload containing text encoded with UTF-8.
327 fin: FIN bit; set it to :obj:`False` if this is the first frame of
328 a fragmented message.
329
330 Raises:
331 ProtocolError: If a fragmented message is in progress.
332
333 """
334 if self.expect_continuation_frame:
335 raise ProtocolError("expected a continuation frame")
336 if self._state is not OPEN:
337 raise InvalidState(f"connection is {self.state.name.lower()}")
338 self.expect_continuation_frame = not fin
339 self.send_frame(Frame(OP_TEXT, data, fin))
340
341 def send_binary(self, data: BytesLike, fin: bool = True) -> None:
342 """

Calls 4

send_frameMethod · 0.95
ProtocolErrorClass · 0.85
InvalidStateClass · 0.85
FrameClass · 0.70