Function: broadcastReconnectNotification()
On this page
broadcastReconnectNotification(
wss,opts?):void
Defined in: packages/server/src/adapters/ws.ts:1072
Tells every open client of a WebSocket server to reconnect, for example
before a deploy. Use it where you have the server but not the handler
applyWSSHandler returns, such as fastify.websocketServer with the
Fastify adapter. Every open client gets the message, including ones that
tRPC doesn't serve.
Parameters
| Parameter | Type | Description |
|---|---|---|
wss | Pick<WSServer<WSClient>, "clients"> | - |
opts? | { experimental_encoder: Encoder; } | - |
opts.experimental_encoder? | Encoder | The encoder the server was set up with, if not JSON. Default jsonEncoder |
Returns
void
Example
broadcastReconnectNotification(fastify.websocketServer);
await fastify.close();See
https://trpc.io/docs/server/adapters/fastify#telling-clients-to-reconnect