repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve payload type checking in OCPP, UI and Broadcast Channel
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
WorkerBroadcastChannel.ts
diff --git
a/src/charging-station/WorkerBroadcastChannel.ts
b/src/charging-station/WorkerBroadcastChannel.ts
index 2099d695ab683e75d315151e02c9c5914eb6cedd..12a877c12add623365c0c8c6c6068c62841000d2 100644
(file)
--- a/
src/charging-station/WorkerBroadcastChannel.ts
+++ b/
src/charging-station/WorkerBroadcastChannel.ts
@@
-2,8
+2,8
@@
import { BroadcastChannel } from 'worker_threads';
import { BroadcastChannelRequest, BroadcastChannelResponse } from '../types/WorkerBroadcastChannel';
import { BroadcastChannelRequest, BroadcastChannelResponse } from '../types/WorkerBroadcastChannel';
-export default class WorkerBroadcastChannel extends BroadcastChannel {
- constructor() {
+export default
abstract
class WorkerBroadcastChannel extends BroadcastChannel {
+
protected
constructor() {
super('worker');
}
super('worker');
}
@@
-11,7
+11,15
@@
export default class WorkerBroadcastChannel extends BroadcastChannel {
this.postMessage(request);
}
this.postMessage(request);
}
- p
ublic
sendResponse(response: BroadcastChannelResponse): void {
+ p
rotected
sendResponse(response: BroadcastChannelResponse): void {
this.postMessage(response);
}
this.postMessage(response);
}
+
+ protected isRequest(message: any): boolean {
+ return Array.isArray(message) && message.length === 3;
+ }
+
+ protected isResponse(message: any): boolean {
+ return Array.isArray(message) && message.length === 2;
+ }
}
}