From f639a4e2881e62f1c15dc3a0115e152ed93c95ab Mon Sep 17 00:00:00 2001 From: Dan5py Date: Sat, 17 Dec 2022 00:58:12 +0100 Subject: [PATCH] Update docs (add default events) --- .../source/getting-started/default_client.rst | 33 ++++++++++++++++ .../source/getting-started/default_events.rst | 15 ++++++++ .../source/getting-started/default_server.rst | 38 +++++++++++++++++++ docs/source/getting-started/index.rst | 3 +- 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 docs/source/getting-started/default_client.rst create mode 100644 docs/source/getting-started/default_events.rst create mode 100644 docs/source/getting-started/default_server.rst diff --git a/docs/source/getting-started/default_client.rst b/docs/source/getting-started/default_client.rst new file mode 100644 index 0000000..bc9cf04 --- /dev/null +++ b/docs/source/getting-started/default_client.rst @@ -0,0 +1,33 @@ +Client side +----------- + +.. py:data:: connect + + Fired when the client connects to the server. + + Returns: ``None`` + +.. py:data:: disconnect + + + Fired when the client disconnects from the server. + + Returns: ``None`` + +.. py:data:: message + + Fired when the server emits an event to the client. + + Returns a ``tuple`` of: + + * ``event``: The name of the emitted event. + * ``data``: The data emitted by the server. + +.. py:data:: error + + Fired when an uncaught exception occurs in the client. + If you don't handle this event, the client will raise the exception. + + Returns: + + * ``error``: The exception message. \ No newline at end of file diff --git a/docs/source/getting-started/default_events.rst b/docs/source/getting-started/default_events.rst new file mode 100644 index 0000000..279025e --- /dev/null +++ b/docs/source/getting-started/default_events.rst @@ -0,0 +1,15 @@ +Default events +========================== + +Some connection-related events are fired by default. You can handle them by adding a listener with the ``.on()`` method, just like any other event. + + +.. toctree:: + + default_server + default_client + +Learn more +---------- + +- :doc:`Library references <../references/index>` \ No newline at end of file diff --git a/docs/source/getting-started/default_server.rst b/docs/source/getting-started/default_server.rst new file mode 100644 index 0000000..011577b --- /dev/null +++ b/docs/source/getting-started/default_server.rst @@ -0,0 +1,38 @@ +Server side +----------- +The following events are fired by default on the server side: + + +.. py:data:: connection + + Fired when a client connects to the server. + + Returns: + + * ``client_id``: The new client's socket UUID. + +.. py:data:: disconnect + + Fired when a client disconnects from the server. + + Returns: + + * ``client_id``: The client's socket UUID. + +.. py:data:: message + + Fired when a client emits an event to the server. + + Returns a ``tuple`` of: + + * ``event``: The name of the emitted event. + * ``data``: The data emitted by the client. + +.. py:data:: error + + Fired when an uncaught exception occurs in the server. + If you don't handle this event, the server will raise the exception. + + Returns: + + * ``error``: The exception message. diff --git a/docs/source/getting-started/index.rst b/docs/source/getting-started/index.rst index f87a6f5..dd6158e 100644 --- a/docs/source/getting-started/index.rst +++ b/docs/source/getting-started/index.rst @@ -29,4 +29,5 @@ Learn how to build a client and a server application with socketsc. server client - removelisteners \ No newline at end of file + removelisteners + default_events \ No newline at end of file