Commit | Line | Data |
---|---|---|
32de5a57 LM |
1 | import { BroadcastChannel } from 'worker_threads'; |
2 | ||
02a6943a | 3 | import { BroadcastChannelRequest, BroadcastChannelResponse } from '../types/WorkerBroadcastChannel'; |
4e3ff94d | 4 | |
32de5a57 LM |
5 | export default class WorkerBroadcastChannel extends BroadcastChannel { |
6 | constructor() { | |
7 | super('worker'); | |
8 | } | |
4e3ff94d JB |
9 | |
10 | public sendRequest(request: BroadcastChannelRequest): void { | |
11 | this.postMessage(request); | |
12 | } | |
02a6943a JB |
13 | |
14 | public sendResponse(response: BroadcastChannelResponse): void { | |
15 | this.postMessage(response); | |
16 | } | |
32de5a57 | 17 | } |