+
+ protected isRequest(message: JsonType[]): boolean {
+ return Array.isArray(message) && message.length === 3;
+ }
+
+ protected isResponse(message: JsonType[]): boolean {
+ return Array.isArray(message) && message.length === 2;
+ }
+
+ protected validateMessageEvent(messageEvent: MessageEvent): MessageEvent | false {
+ if (Array.isArray(messageEvent.data) === false) {
+ logger.error(
+ this.logPrefix(moduleName, 'validateMessageEvent') +
+ ' Worker broadcast channel protocol message event data is not an array'
+ );
+ return false;
+ }
+ if (uuid.validate(messageEvent.data[0]) === false) {
+ logger.error(
+ this.logPrefix(moduleName, 'validateMessageEvent') +
+ ' Worker broadcast channel protocol message event data UUID field is invalid'
+ );
+ return false;
+ }
+ return messageEvent;
+ }
+
+ private logPrefix(modName: string, methodName: string): string {
+ return Utils.logPrefix(` Worker Broadcast Channel | ${modName}.${methodName}:`);
+ }