-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from HyperionGray/create_docs
Create docs
- Loading branch information
Showing
17 changed files
with
991 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = | ||
SPHINXBUILD = sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is just a placeholder file because this project doesn't | ||
have any static assets. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
API | ||
=== | ||
|
||
.. currentmodule:: trio_websocket | ||
|
||
In addition to the convenience functions documented in :ref:`websocket-clients` | ||
and :ref:`websocket-servers`, the API has several important classes described | ||
on this page. | ||
|
||
Requests | ||
-------- | ||
|
||
.. class:: WebSocketRequest | ||
|
||
A request object presents the client's handshake to a server handler. The | ||
server can inspect handshake properties like HTTP headers, subprotocols, etc. | ||
The server can also set some handshake properties like subprotocol. The | ||
server should call :meth:`accept` to complete the handshake and obtain a | ||
connection object. | ||
|
||
.. autoattribute:: headers | ||
.. autoattribute:: proposed_subprotocols | ||
.. autoattribute:: subprotocol | ||
.. autoattribute:: url | ||
.. automethod:: accept | ||
|
||
Connections | ||
----------- | ||
|
||
.. class:: WebSocketConnection | ||
|
||
A connection object has functionality for sending and receiving messages, | ||
pinging the remote endpoint, and closing the WebSocket. | ||
|
||
.. note:: | ||
|
||
The preferred way to obtain a connection is to use one of the | ||
convenience functions described in :ref:`websocket-clients` or | ||
:ref:`websocket-servers`. Instantiating a connection instance directly is | ||
tricky and is not recommended. | ||
|
||
This object has properties that expose connection metadata. | ||
|
||
.. autoattribute:: is_closed | ||
.. autoattribute:: close_reason | ||
.. autoattribute:: is_client | ||
.. autoattribute:: is_server | ||
.. autoattribute:: path | ||
.. autoattribute:: subprotocol | ||
|
||
A connection object has a pair of methods for sending and receiving | ||
WebSocket messages. Messages can be ``str`` or ``bytes`` objects. | ||
|
||
.. automethod:: send_message | ||
.. automethod:: get_message | ||
|
||
A connection object also has methods for sending pings and pongs. Each ping | ||
is sent with a unique payload, and the function blocks until a corresponding | ||
pong is received from the remote endpoint. This feature can be used to | ||
implement a bidirectional heartbeat. | ||
|
||
A pong, on the other hand, sends an unsolicited pong to the remote endpoint | ||
and does not expect or wait for a response. This feature can be used to | ||
implement a unidirectional heartbeat. | ||
|
||
.. automethod:: ping | ||
.. automethod:: pong | ||
|
||
Finally, the socket offers a method to close the connection. The connection | ||
context managers in :ref:`websocket-clients` and :ref:`websocket-servers` | ||
will automatically close the connection for you, but you may want to close | ||
the connection explicity if you are not using a context manager or if you | ||
want to customize the close reason. | ||
|
||
.. automethod:: aclose | ||
|
||
.. autoclass:: CloseReason | ||
:members: | ||
|
||
.. autoexception:: ConnectionClosed |
Oops, something went wrong.