Third-Party WebSockets #

CastHub interfaces with third-party WebSockets and manages them, sharing connections through different modules making sure to not duplicate already-existing connections, as well as removing the need to authenticate.

Currently only the following Integrations have WebSocket support:

Opening a Connection #

All you need to open a new connection is an Identity ID, provided the Integration for that Identity supports WebSockets (See above list).

mounted() {
    const { id } = this.identities[0];

    return super.mounted().then(() => {
        return window.casthub.ws(id);
    }).then(ws => {
        // You can listen to whatever events are emitted from the service.
        ws.on('event', data => {
            console.log('NEW EVENT', data);
        });
    });
}

If a connection to that specific Identity is already open (For example, when another Module has already opened it), you will be subscribed to events from that instance straight away and won't need to wait for a new connection to open.

Events #

For the foreseeable future, we won't be transforming any of the events from the different Integration's WebSockets. All ws instances will emit the same raw events as if you opened the connection yourself, so refer to the API Docs of the Integration for a full list of supported events.