Skip to content

Commit

Permalink
Update docs (add default events)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan5py committed Dec 16, 2022
1 parent 13d765a commit f639a4e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
33 changes: 33 additions & 0 deletions docs/source/getting-started/default_client.rst
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions docs/source/getting-started/default_events.rst
Original file line number Diff line number Diff line change
@@ -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>`
38 changes: 38 additions & 0 deletions docs/source/getting-started/default_server.rst
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion docs/source/getting-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Learn how to build a client and a server application with socketsc.

server
client
removelisteners
removelisteners
default_events

0 comments on commit f639a4e

Please sign in to comment.