Skip to content

Commit

Permalink
Add documentation.
Browse files Browse the repository at this point in the history
Ref #478.
  • Loading branch information
aaugustin committed Nov 4, 2018
1 parent 2e45ba7 commit 1d97ab5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Changelog
**Version 8.0 adds the reason phrase to the return type of the low-level
API** :func:`~http.read_response` **.**

Also:

* :meth:`~protocol.WebSocketCommonProtocol.send`,
:meth:`~protocol.WebSocketCommonProtocol.ping`, and
:meth:`~protocol.WebSocketCommonProtocol.pong` support bytes-like types
:class:`bytearray` and :class:`memoryview` in addition to :class:`bytes`.

7.0
...

Expand Down
15 changes: 8 additions & 7 deletions src/websockets/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,11 @@ def send(self, data):
"""
This coroutine sends a message.
It sends :class:`str` as a text frame and :class:`bytes` as a binary
frame.
It sends a string (:class:`str`) as a text frame and a bytes-like
object (:class:`bytes`, :class:`bytearray`, or :class:`memoryview`)
as a binary frame.
It also accepts an iterable of :class:`str` or :class:`bytes`. Each
It also accepts an iterable of strings or bytes-like objects. Each
item is treated as a message fragment and sent in its own frame. All
items must be of the same type, or else :meth:`send` will raise a
:exc:`TypeError` and the connection will be closed.
Expand Down Expand Up @@ -572,8 +573,8 @@ def ping(self, data=None):
await pong_waiter # only if you want to wait for the pong
By default, the ping contains four random bytes. The content may be
overridden with the optional ``data`` argument which must be of type
:class:`str` (which will be encoded to UTF-8) or :class:`bytes`.
overridden with the optional ``data`` argument which must be a string
(which will be encoded to UTF-8) or a bytes-like object.
"""
yield from self.ensure_open()
Expand Down Expand Up @@ -603,8 +604,8 @@ def pong(self, data=b''):
An unsolicited pong may serve as a unidirectional heartbeat.
The content may be overridden with the optional ``data`` argument
which must be of type :class:`str` (which will be encoded to UTF-8) or
:class:`bytes`.
which must be a string (which will be encoded to UTF-8) or a
bytes-like object.
"""
yield from self.ensure_open()
Expand Down

0 comments on commit 1d97ab5

Please sign in to comment.