refactor(): remove redundancy, extract handleEvent

This commit is contained in:
Kamil Myśliwiec
2019-03-01 10:11:19 +01:00
parent 0cc1c4ebea
commit 9f1a32cbfd
9 changed files with 94 additions and 52 deletions

View File

@@ -7,7 +7,6 @@ import {
CLOSE_EVENT,
ERROR_EVENT,
MESSAGE_EVENT,
NO_EVENT_HANDLER,
NO_MESSAGE_HANDLER,
TCP_DEFAULT_PORT,
} from '../constants';
@@ -77,14 +76,6 @@ export class ServerTCP extends Server implements CustomTransportStrategy {
);
}
public async handleEvent(pattern: string, packet: ReadPacket): Promise<any> {
const handler = this.getHandlerByPattern(pattern);
if (!handler) {
return this.logger.error(NO_EVENT_HANDLER);
}
await handler(packet.data);
}
public handleClose(): undefined | number | NodeJS.Timer {
if (
this.isExplicitlyTerminated ||