Skip to content

Commit

Permalink
Add wsproto.Connection reference
Browse files Browse the repository at this point in the history
  • Loading branch information
MtkN1 authored and Kriechi committed Feb 24, 2024
1 parent 9423fc0 commit 2abd24c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,10 @@ Connection
:special-members: __init__
:members:

.. autoclass:: wsproto.Connection
:special-members: __init__
:members:

.. autoclass:: wsproto.ConnectionType
:members:

Expand Down
15 changes: 10 additions & 5 deletions src/wsproto/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 63,6 @@ class Connection:
This wraps two other protocol objects, an HTTP/1.1 protocol object used
to do the initial HTTP upgrade handshake and a WebSocket frame protocol
object used to exchange messages and other control frames.
:param conn_type: Whether this object is on the client- or server-side of
a connection. To initialise as a client pass ``CLIENT`` otherwise
pass ``SERVER``.
:type conn_type: ``ConnectionType``
"""

def __init__(
Expand All @@ -76,6 71,16 @@ def __init__(
extensions: Optional[List[Extension]] = None,
trailing_data: bytes = b"",
) -> None:
"""
Constructor
:param wsproto.connection.ConnectionType connection_type: Whether this
object is on the client- or server-side of a connection.
To initialise as a client pass ``CLIENT`` otherwise pass ``SERVER``.
:param list extensions: The proposed extensions.
:param bytes trailing_data: Data that has been received, but not yet
processed.
"""
self.client = connection_type is ConnectionType.CLIENT
self._events: Deque[Event] = deque()
self._proto = FrameProtocol(self.client, extensions or [])
Expand Down

0 comments on commit 2abd24c

Please sign in to comment.