import { URL } from 'url';
import { parentPort } from 'worker_threads';
-import WebSocket, { Data, RawData } from 'ws';
+import WebSocket, { type RawData } from 'ws';
import BaseError from '../exception/BaseError';
import OCPPError from '../exception/OCPPError';
}
}
- private async onClose(code: number, reason: string): Promise<void> {
+ private async onClose(code: number, reason: Buffer): Promise<void> {
switch (code) {
// Normal close
case WebSocketCloseEventStatusCode.CLOSE_NORMAL:
logger.info(
`${this.logPrefix()} WebSocket normally closed with status '${Utils.getWebSocketCloseEventStatusString(
code
- )}' and reason '${reason}'`
+ )}' and reason '${reason.toString()}'`
);
this.autoReconnectRetryCount = 0;
break;
logger.error(
`${this.logPrefix()} WebSocket abnormally closed with status '${Utils.getWebSocketCloseEventStatusString(
code
- )}' and reason '${reason}'`
+ )}' and reason '${reason.toString()}'`
);
this.started === true && (await this.reconnect());
break;
parentPort.postMessage(MessageChannelUtils.buildUpdatedMessage(this));
}
- private async onMessage(data: Data): Promise<void> {
+ private async onMessage(data: RawData): Promise<void> {
let messageType: number;
let messageId: string;
let commandName: IncomingRequestCommand;