1+ import ws , { WebSocket } from 'ws'
12import cluster from 'cluster'
23import { EventEmitter } from 'stream'
34import { IncomingMessage as IncomingHttpMessage } from 'http'
4- import { WebSocket } from 'ws'
55
66import { ContextMetadata , Factory } from '../@types/base'
77import { createNoticeMessage , createOutgoingEventMessage } from '../utils/messages'
@@ -22,7 +22,7 @@ import { Settings } from '../@types/settings'
2222import { SocketAddress } from 'net'
2323
2424( ( ) => {
25- ( WebSocket as any ) . Receiver . prototype . _write = function _write ( chunk : any , _encoding : any , cb : any ) {
25+ ( ws as any ) . Receiver . prototype . _write = function _write ( chunk : any , _encoding : any , cb : any ) {
2626 if ( this . _opcode === 0x08 && this . _state == 0 ) return cb ( )
2727
2828 this . _bufferedBytes += chunk . length
@@ -68,6 +68,8 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
6868 family : address . indexOf ( ':' ) >= 0 ? 'ipv6' : 'ipv4' ,
6969 } )
7070
71+ console . log ( `web-socket-adapter: new client ${ this . clientId } (${ this . getClientAddress ( ) } )` )
72+
7173 this . client
7274 . on ( 'error' , ( error ) => {
7375 if ( error . name === 'RangeError' && error . message === 'Max payload size exceeded' ) {
@@ -274,6 +276,6 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
274276 this . removeAllListeners ( )
275277 this . client . removeAllListeners ( )
276278
277- debug ( 'client %s closed' , this . clientId )
279+ console . error ( `web-socket-adapter: disconnected client ${ this . clientId } ( ${ this . getClientAddress ( ) } )` )
278280 }
279281}
0 commit comments