This commit is contained in:
nvms 2025-04-21 11:48:04 -04:00
parent fe163324df
commit c448abfecc

View File

@ -456,6 +456,19 @@ const allMetadata = await Promise.all(
// [{ userId: "user123", username: "Alice", avatar: "..." }, ...]
```
> [!NOTE]
> Mesh tracks presence and presence state **per connection**, not per user.
>
> If a user opens multiple browser tabs (or devices), each will be assigned a **separate connection ID** and have an **independent presence state**.
>
> Even if both tabs authenticate with the same user ID and you store these values in connection metadata, Mesh does not merge or deduplicate those connections.
>
> If you want to show a single presence indicator per user (e.g. only one "typing" icon), you should:
>
> 1. Attach a `userId` to each connection's metadata
> 2. Resolve metadata for each `connectionId` client-side
> 3. Deduplicate by `userId` in your UI logic
> [!TIP]
> You can expose a `get-user-metadata` command on the server that reads from `connectionManager.getMetadata(...)` to support this.