Mixer

API

All Modules for Mixer are given access to make requests on the Users' behalf. All requests are automatically authenticated.

Here is an example of requesting the current User from Mixer:

const response = await window.casthub.fetch({
    integration: 'mixer',
    method: 'GET',
    url: 'users/current',
});

This supports the Mixer REST API endpoints.

Chat

All you need to open a new connection is an Identity ID, provided by the User during installation.

async mounted() {
    await super.mounted();

    const { id } = this.identity;

    // Connect to the Chat System.
    const chat = await window.casthub.chat(id);

    // And listen for new messages.
    chat.on('message', data => {
        console.log('NEW MESSAGE', 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.