<commit_before>Asynchronous Backend-Frontend Communication Via Web Sockets
===========================================================

The basic idea is very simple: clients need to be able to subscribe and
unsubscribe to (changes of) a given object.  If an object changes and a client
is subscribed to it, that client will receive a notification.

We implement this by opening one web-socket per client (= frontend) at the
beginning of a session.  Subscribe and unsubscribe requests are sent from
client to server (= backend), and change notifications are sent from server to
client.  The client is responsible to handle and dispatch each particular
change to the parts of the GUI that care about it.


Client Messages
---------------

Both client and server send messages in JSON format.

Client messages have the following structure::

    { "action": "ACTION", "resource": "RESOURCE_PATH" }

ACTION is one of:

* "subscribe" to start receiving updates about a resource. If the client has
  already sent an earlier subscribe request for that resource, the new request
  is silently ignored.
* "unsubscribe" to stop receiving updates about a resource. If the client
  is not currently subscribed to that resource, the request is silently
  ignored.

For example::

    { "action": "subscribe", "resource": "/adhocracy/prop1/" }

And later::

    { "action": "unsubscribe", "resource": "/adhocracy/prop1/" }


Server Messages
---------------

Responses to Client Messages
++++++++++++++++++++++++++++

Status Confirmations
~~~~~~~~~~~~~~~~~~~~

If a client request was processed successfully by the server, it sends a status
confirmation:

    { "status": "STATUS", "action": "ACTION", "resource": "RESOURCE_PATH" }<commit_msg>Fixup: rst syntax<commit_after>Asynchronous Backend-Frontend Communication Via Web Sockets
===========================================================

The basic idea is very simple: clients need to be able to subscribe and
unsubscribe to (changes of) a given object.  If an object changes and a client
is subscribed to it, that client will receive a notification.

We implement this by opening one web-socket per client (= frontend) at the
beginning of a session.  Subscribe and unsubscribe requests are sent from
client to server (= backend), and change notifications are sent from server to
client.  The client is responsible to handle and dispatch each particular
change to the parts of the GUI that care about it.


Client Messages
---------------

Both client and server send messages in JSON format.

Client messages have the following structure::

    { "action": "ACTION", "resource": "RESOURCE_PATH" }

ACTION is one of:

* "subscribe" to start receiving updates about a resource. If the client has
  already sent an earlier subscribe request for that resource, the new request
  is silently ignored.
* "unsubscribe" to stop receiving updates about a resource. If the client
  is not currently subscribed to that resource, the request is silently
  ignored.

For example::

    { "action": "subscribe", "resource": "/adhocracy/prop1/" }

And later::

    { "action": "unsubscribe", "resource": "/adhocracy/prop1/" }


Server Messages
---------------

Responses to Client Messages
++++++++++++++++++++++++++++

Status Confirmations
~~~~~~~~~~~~~~~~~~~~

If a client request was processed successfully by the server, it sends a status
confirmation::

    { "status": "STATUS", "action": "ACTION", "resource": "RESOURCE_PATH" }
{'fraction_non_alphanumeric': 0.14149581287900664, 'fraction_numerical': 0.001155067860236789, 'mean_word_length': 4.2724505327245055, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6170057', 'n_tokens_mistral': 876, 'n_tokens_neox': 823, 'n_words': 436}