Skip to content

DisconnectUser

Source: src/AWS/IVSChat/DisconnectUser.ts

Moderate the bound room by disconnecting all WebSocket connections of a user — the effectful call made from a deployed Lambda or Task. The userId is the one the user’s chat token was minted with; disconnection does not prevent reconnection, so revoke by not minting further tokens. The call succeeds even when the user has no open connections.

Provide the DisconnectUserHttp implementation layer on the Function effect, bind the room in the init phase, then call the returned client at runtime. The binding grants ivschat:DisconnectUser on the room and injects its ARN as the roomIdentifier automatically.

// init
const room = yield* IVSChat.Room("LiveChat");
const disconnectUser = yield* IVSChat.DisconnectUser(room);
return {
fetch: Effect.gen(function* () {
// runtime
yield* disconnectUser({ userId: "user-123", reason: "spam" });
return HttpServerResponse.json({ ok: true });
}),
};
// on the Function effect:
// .pipe(Effect.provide(IVSChat.DisconnectUserHttp))