fix path mounting

This commit is contained in:
SrGooglo 2025-03-31 22:28:31 +00:00
parent 4ced55f293
commit 68e5fdfecb
2 changed files with 4 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import BuiltInEvents from "./events"
class RTEngineNG {
constructor(config = {}) {
this.config = config
this.events = new Map()
if (typeof config.events === "object") {
@ -24,8 +25,6 @@ class RTEngineNG {
clients = new Map()
router = new HyperExpress.Router()
senders = {
broadcast: async (event, data) => {
for (const [socketId, client] of this.clients) {
@ -153,10 +152,8 @@ class RTEngineNG {
attach = async (engine) => {
this.engine = engine
this.router.ws("/", this.handleConnection)
this.router.upgrade("/", this.handleUpgrade)
this.engine.app.use("/", this.router)
this.engine.app.ws(this.config.path ?? `/`, this.handleConnection)
this.engine.app.upgrade(this.config.path ?? `/`, this.handleUpgrade)
}
close = () => {

View File

@ -67,6 +67,7 @@ export default class HyperExpressEngineNG {
if (this.ctx.constructor.enableWebsockets === true) {
this.ws = global.websocket = new rtengineng({
path: this.ctx.constructor.wsPath,
onUpgrade: this.ctx.handleWsUpgrade,
onConnection: this.ctx.handleWsConnection,
onDisconnect: this.ctx.handleWsDisconnect,