WebSocket work
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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`)))
|
||||
})
|
||||
}),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user