adhocracy_core.websockets.server module¶
Classes used by the standalone Websocket server.
-
class
ClientTracker[source]¶ Bases:
objectKeeps track of the clients that want notifications.
Initialize self.
-
is_subscribed(client: collections.abc.Hashable, resource: <InterfaceClass adhocracy_core.interfaces.IResource>) → bool[source]¶ Check whether a client is subscribed to a resource.
-
subscribe(client: collections.abc.Hashable, resource: <InterfaceClass adhocracy_core.interfaces.IResource>) → bool[source]¶ Subscribe a client to a resource, if necessary.
Returns: True if the subscription was successful, False if it was unnecessary (the client was already subscribed).
-
unsubscribe(client: collections.abc.Hashable, resource: <InterfaceClass adhocracy_core.interfaces.IResource>) → bool[source]¶ Unsubscribe a client from a resource, if necessary.
Returns: True if the unsubscription was successful, False if it was unnecessary (the client was not subscribed).
-
delete_subscriptions_for_client(client: collections.abc.Hashable)[source]¶ Delete all subscriptions for a client.
-
-
class
DummyRequest(application_url, root)[source]¶ Bases:
objectDummy request to create/resolve resource urls.
This is needed to de/serialize SchemaNodes with
adhocracy_core.schema.ResourceObjectschema type.Initialize self.
-
application_url= None¶ URL prefix used to extract resource paths.
-
root= None¶ The root resource to resolve resource paths
-
-
class
ClientCommunicator[source]¶ Bases:
autobahn.asyncio.websocket.WebSocketServerProtocolCommunicates with a client through a WebSocket connection.
Note that the zodb_connection attribute must be set instances of this class can be used!
-
zodb_database= None¶
-
rest_url= 'http://localhost:6541'¶
-
send_notification(resource: <InterfaceClass adhocracy_core.interfaces.IResource>, event_type: str)[source]¶ Send notification about an event affecting a resource.
-
send_child_notification(status: str, resource: <InterfaceClass adhocracy_core.interfaces.IResource>, child: <InterfaceClass adhocracy_core.interfaces.IResource>)[source]¶ Send notification concerning a child resource.
Parameters: status ( str) – should be ‘new’, ‘removed’, or ‘modified’
-