// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import { WebRtcHandler } from "./handler.js";
const handler = new WebRtcHandler();
self.addEventListener("message", (event) => {
    if (event.data.kind === 'genericMessage') {
        handler.handleGeneric(event.data.data.message);
    }
    else if (event.data.kind === 'systemMessage') {
        handler.handleSystem(event.data.data.message);
    }
    else if (event.data.kind === 'serviceCall') {
        handler.handleServiceCall(event.data.data.message);
    }
    else if (event.data.kind === 'rawSend') {
        handler.handleRawSend({
            channel: event.data.data.message.channel,
            data: event.data.data.message.message
        });
    }
    else if (event.data.kind === 'subscribe') {
        handler.subscribe(event.data.data.message.topics);
    }
    else if (event.data.kind === 'unsubscribe') {
        handler.unsubscribe(event.data.data.message.topics);
    }
    else if (event.data.kind === 'disconnect') {
        handler.handleDisconnect(event.data.error);
    }
    else {
        handler.handleConnection(event.data.data);
    }
});
//# sourceMappingURL=worker.js.map