1- import ws , { WebSocket } from 'ws'
21import cluster from 'cluster'
32import { EventEmitter } from 'stream'
43import { IncomingMessage as IncomingHttpMessage } from 'http'
4+ import { WebSocket } from 'ws'
55
66import { ContextMetadata , Factory } from '../@types/base'
77import { createNoticeMessage , createOutgoingEventMessage } from '../utils/messages'
@@ -21,20 +21,6 @@ import { messageSchema } from '../schemas/message-schema'
2121import { Settings } from '../@types/settings'
2222import { SocketAddress } from 'net'
2323
24- ( ( ) => {
25- ( ws as any ) . Receiver . prototype . _write = function _write ( chunk : any , _encoding : any , cb : any ) {
26- if ( this . _opcode === 0x08 && this . _state == 0 ) return cb ( )
27-
28- this . _bufferedBytes += chunk . length
29- this . _buffers . push ( chunk )
30- try {
31- this . startLoop ( cb )
32- } catch ( error ) {
33- console . error ( 'what in the world' , error )
34- cb ( error )
35- }
36- }
37- } ) ( )
3824
3925const debug = createLogger ( 'web-socket-adapter' )
4026const debugHeartbeat = debug . extend ( 'heartbeat' )
@@ -68,8 +54,6 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
6854 family : address . indexOf ( ':' ) >= 0 ? 'ipv6' : 'ipv4' ,
6955 } )
7056
71- console . log ( `web-socket-adapter: new client ${ this . clientId } (${ this . getClientAddress ( ) } ) - ${ ( this . webSocketServer as any ) . webSocketServer . clients . size } total on worker ${ process . pid } ` )
72-
7357 this . client
7458 . on ( 'error' , ( error ) => {
7559 if ( error . name === 'RangeError' && error . message === 'Max payload size exceeded' ) {
@@ -282,7 +266,5 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
282266
283267 this . removeAllListeners ( )
284268 this . client . removeAllListeners ( )
285-
286- console . error ( `web-socket-adapter: disconnected client ${ this . clientId } (${ this . getClientAddress ( ) } ) - ${ ( this . webSocketServer as any ) . webSocketServer . clients . size } total on worker ${ process . pid } ` )
287269 }
288270}
0 commit comments