20 lines
418 B
JavaScript
20 lines
418 B
JavaScript
import Client from './client.js';
|
|
|
|
export default class LocalClient extends Client {
|
|
async connect() {
|
|
this.worker = new Worker(
|
|
new URL('../server/worker.js', import.meta.url),
|
|
{type: 'module'},
|
|
);
|
|
this.worker.onmessage = (event) => {
|
|
this.accept(event.data);
|
|
};
|
|
}
|
|
disconnect() {
|
|
this.worker.terminate();
|
|
}
|
|
transmit(packed) {
|
|
this.worker.postMessage(packed);
|
|
}
|
|
}
|