@cuboapp/ws 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/server/index.ts
CHANGED
|
@@ -90,6 +90,8 @@ export class WsServer<C = {}> {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
this.clients.delete(socket)
|
|
93
|
+
|
|
94
|
+
this.opts?.onDisconnect?.(socket)
|
|
93
95
|
})
|
|
94
96
|
|
|
95
97
|
socket.addListener('message', (e) => {
|
|
@@ -107,6 +109,8 @@ export class WsServer<C = {}> {
|
|
|
107
109
|
})
|
|
108
110
|
|
|
109
111
|
this.clients.add(socket)
|
|
112
|
+
|
|
113
|
+
this.opts?.onConnect?.(socket)
|
|
110
114
|
})
|
|
111
115
|
|
|
112
116
|
this.inited = true
|
|
@@ -16,6 +16,9 @@ export type WsServerOptions<C extends unknown> = {
|
|
|
16
16
|
}
|
|
17
17
|
debug?: boolean
|
|
18
18
|
http?: Partial<HttpServerOptions<C>>
|
|
19
|
+
|
|
20
|
+
onConnect?: (socket: WsServerSocket<C>) => void | Promise<void>
|
|
21
|
+
onDisconnect?: (socket: WsServerSocket<C>) => void | Promise<void>
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export type WsServerHandler<C, D extends unknown = object> = (
|