feat: modify ws on Message params

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-05-26 18:48:46 +08:00
parent 78fcbbe9a5
commit 95cd8c4889

View File

@ -31,15 +31,13 @@ class TomcatWebSocketServer extends EventEmitter {
this.allClients[tomcatClient.id] = tomcatClient this.allClients[tomcatClient.id] = tomcatClient
this.emit(ServerEvent.connect, tomcatClient) this.emit(ServerEvent.connect, tomcatClient)
}, },
onMessage: (message: any, session: TomcatWebSocketSession) => { onMessage: (session: TomcatWebSocketSession, message: string) => {
this.executor.execute(() => { this.executor.execute(() => this.emit(ServerEvent.message, this.allClients[session.getId()], message))
this.emit(ServerEvent.message, this.allClients[session.getId()], message)
})
}, },
onClose: (session: TomcatWebSocketSession, reason: any) => { onClose: (session: TomcatWebSocketSession, reason: any) => {
this.emit(ServerEvent.disconnect, this.allClients[session.getId()], reason) this.emit(ServerEvent.disconnect, this.allClients[session.getId()], reason)
}, },
onError: (session: TomcatWebSocketSession, error: any) => { onError: (session: TomcatWebSocketSession, error: Error) => {
this.emit(ServerEvent.error, this.allClients[session.getId()], error) this.emit(ServerEvent.error, this.allClients[session.getId()], error)
}, },
}) })