Hi Marco,

> Instead it would be nice to have isolated channels end-to-end for
> instance by using the id of the logged user.

I’ll give you some hints to the existing architecture, maybe that’s helpful:

• If you create a new websocket connection, a unique ID is created.
• With ws:id, you get your own ID, i.e., the ID of the client that
created the current connection [1].
• You can use ws:send($message, ws:id()) to send a message to exactly
this client.
• With ws:set, you can store additional user properties, such as e.g.
session data, which you can access later on.

I assume you already had a look at our chat application [2]. It allows
you to send requests to all users or only specific users. The
'specific user' could also be yourself. Feel free to ask if not
self-explanatory (I remember it contains a lot of clever code in just
a few lines…).

[1] https://docs.basex.org/wiki/WebSocket_Module#ws%3Aid
[2] https://github.com/BaseXdb/basex/tree/main/basex-api/src/main/webapp/chat

Reply via email to