serverWebSocketActorOf
serverWebSocketActorOf(
system,socket,opts?):ActorRef<WebSocketCmd>
Defined in: src/io/broker/WebSocketServerAdapters.ts:52
Spawn a ServerWebSocketActor bound to an already-upgraded socket. Use this from a Fastify-websocket handler:
fastify.register(import(‘@fastify/websocket’));
fastify.get(‘/ws’, { websocket: true }, (conn, _req) => {
const ref = serverWebSocketActorOf(system, conn.socket, {
target: chatRoom,
name: () => ws-${nextId()},
});
chatRoom.tell({ kind: ‘join’, client: ref });
});
socket must satisfy ServerWebSocketLike — Fastify’s
conn.socket, the ws package’s WebSocket, and Hono’s
Node-WS-bound socket all do.
Parameters
Section titled “Parameters”system
Section titled “system”socket
Section titled “socket”ServerWebSocketActorOptions & object = {}