Writer¶
You should not make an instance of the WebSocketWriter class yourself, rather you should only
make use of it through websocket.client.Client.writer
>>> client.writer.send('Hello World!')
-
class
websocket.stream.writer.
WebSocketWriter
(writer, loop)[source]¶ Variables: closed – True iff the server has sent a close frame to the client. -
feed
(buffer, op_code=None, chunksize=1024, drain_every=4096, force=False)[source]¶ Feed the contents of a
Buffer
to the client in chunksize fragments.Parameters: - buffer (Buffer) – The buffer to read from
- op_code (int) – The type of data to send, see
DataType
, if None try to read buffer.data_type as if buffer was aWebSocketReader
- chunksize (int) – The size of each fragment
- drain_every (int) – How often we forcefully drain the writer
- force (bool) – If true send message even if the connection is closing e.g. we got valid message after having previously been sent a close frame from the client or after having received invalid frame(s)
-
fragment
()[source]¶ Create a async context manager that can send fragmented messages.
Returns: FragmentContext
-
ping
(payload=b'')[source]¶ Send a ping to the client.
Parameters: payload (bytes) – The payload to send with the ping.
-