mirror of
https://github.com/nvms/prsm.git
synced 2025-12-16 08:00:53 +00:00
README
This commit is contained in:
parent
36eed400b8
commit
0579c0d150
@ -8,7 +8,7 @@ Mesh is a command-based WebSocket framework for real-time applications. It uses
|
|||||||
* [Next steps](#next-steps)
|
* [Next steps](#next-steps)
|
||||||
* [Who is this for?](#who-is-this-for)
|
* [Who is this for?](#who-is-this-for)
|
||||||
* [Distributed messaging architecture](#distributed-messaging-architecture)
|
* [Distributed messaging architecture](#distributed-messaging-architecture)
|
||||||
* [Redis channel subscriptions](#redis-channel-subscriptions)
|
* [Redis channel subscriptions](#redis-channel-subscriptions)
|
||||||
* [Server configuration](#server-configuration)
|
* [Server configuration](#server-configuration)
|
||||||
* [Server publishing](#server-publishing)
|
* [Server publishing](#server-publishing)
|
||||||
* [Client usage](#client-usage)
|
* [Client usage](#client-usage)
|
||||||
@ -158,11 +158,11 @@ sequenceDiagram
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### Redis channel subscriptions
|
## Redis channel subscriptions
|
||||||
|
|
||||||
Mesh lets clients subscribe to Redis pub/sub channels and receive messages directly over their WebSocket connection. When subscribing, clients can optionally request recent message history.
|
Mesh lets clients subscribe to Redis pub/sub channels and receive messages directly over their WebSocket connection. When subscribing, clients can optionally request recent message history.
|
||||||
|
|
||||||
#### Server configuration
|
### Server configuration
|
||||||
|
|
||||||
Expose the channels you want to allow subscriptions to:
|
Expose the channels you want to allow subscriptions to:
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ server.exposeChannel(/^private:chat:.+$/, async (conn, channel) => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Server publishing
|
### Server publishing
|
||||||
|
|
||||||
To publish messages to a channel (which subscribed clients will receive), use the `publishToChannel` method. You can optionally store a history of recent messages in Redis.
|
To publish messages to a channel (which subscribed clients will receive), use the `publishToChannel` method. You can optionally store a history of recent messages in Redis.
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ await server.publishToChannel(
|
|||||||
|
|
||||||
The `history` parameter tells Mesh to store the message in a Redis list (`history:<channel>`) and trim the list to the specified size, ensuring only the most recent messages are kept. Clients subscribing with the `historyLimit` option will receive these historical messages upon connection.
|
The `history` parameter tells Mesh to store the message in a Redis list (`history:<channel>`) and trim the list to the specified size, ensuring only the most recent messages are kept. Clients subscribing with the `historyLimit` option will receive these historical messages upon connection.
|
||||||
|
|
||||||
#### Client usage
|
### Client usage
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const { success, history } = await client.subscribe(
|
const { success, history } = await client.subscribe(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user