WebSocket work

This commit is contained in:
Julien Valverdé
2024-07-11 19:12:07 +02:00
parent 4f688719d7
commit 9ea6188f8b
6 changed files with 10 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
import { Effect, Layer } from "effect"
import { expressHandler } from "trpc-playground/handlers/express"
import { rpcHTTPPlaygroundRoot, rpcHTTPRoot } from "../config"
import { ExpressApp } from "../express/ExpressApp"
import { ExpressApp } from "../http/ExpressApp"
import { RPCRouter } from "./RPCRouter"

View File

@@ -1,7 +1,7 @@
import { createExpressMiddleware } from "@trpc/server/adapters/express"
import { Effect, Layer } from "effect"
import { rpcHTTPRoot } from "../config"
import { ExpressApp } from "../express/ExpressApp"
import { ExpressApp } from "../http/ExpressApp"
import { TRPCContextCreator } from "../trpc/TRPCContextCreator"
import { RPCRouter } from "./RPCRouter"

View File

@@ -1,7 +1,7 @@
import { applyWSSHandler } from "@trpc/server/adapters/ws"
import { Context, Effect, Layer, Runtime } from "effect"
import ws from "ws"
import { ExpressHTTPServer } from "../express/ExpressHTTPServer"
import { ExpressHTTPServer } from "../http/ExpressHTTPServer"
import { TRPCContextCreator } from "../trpc/TRPCContextCreator"
import { RPCRouter } from "./RPCRouter"
@@ -33,8 +33,12 @@ export module RPCWebSocketServer {
}),
({ wss, handler }) => Effect.gen(function*() {
yield* Effect.logInfo(`WebSocket server is closing. Waiting for existing connections to end...`)
handler.broadcastReconnectNotification()
wss.close()
yield* Effect.async(resume => {
wss.close(() => resume(Effect.logInfo(`WebSocket server closed`)))
})
}),
))
}