Socket
Book a DemoInstallSign in
Socket

mixer-chat

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixer-chat

Simplistic module to connect to the Mixer chat servers.

1.0.6-alpha
latest
npmnpm
Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

Mixer Chat

This is a new module which allows you to connect to Mixer Chat Servers.

Some of the code is based of the original chat code from beam-client-node which did it's job but being stuck with the bulky module and bugs. It was easier to create this to just handle chat connections and have better error handling/methods. We plan on expanding this to contain more features and better hooks for developers to use. But for now it's the basic module to connect to chat and stay connected with built in reconnection logic.

There are an array of options you can change with the socket connection. Of which are all typed so please explore the code or mess around in TypeScript to see what's on offer.

To Do

  • Built in channel manager. (To enable users to just request a new channel and the module will connect/manage and send up events)
  • Verbose error handling (Enable more error handling from both Mixer and CloudFlare to enable better reconnecting)
  • In build endpoint handling. (To allow the module to auto refresh the endpoints/authkey for chat connections)

Setup

  • Install the module using npm i mixer-chat --save

Usage

This is a simple usage to connect to a channel chat.

import { ChatSocket, IChatMessage, IUserUpdate } from 'mixer-chat';

/**
 * You will need the channelId of the channel you wish to connect too; and the userId of the user you want to
 * connect to chat as. You can find information about how to do this here: https://dev.mixer.com/reference/chat/index.html#chat__introduction
 **/

async function connect(channelId: number, userId: number, authKey: string) {
    // Create the chat socket.
    const endpoints: string[] = []; // List of endpoints taken from the `chats/:id` endpoint.
    const chat = new ChatSocket(endpoints).boot();

    // Authenticate to the server
    const isAuthed = await chat.auth(channelId, userId, authKey); // Returns the userRoles and if authenticated.

    // You'll now get events from the server on new messages/events etc...
    chat.on('ChatMessage', (message: IChatMessage) => {
        console.log(message);
    });
    chat.on('UserUpdate', (update: IUserUpdate) => {
        console.log(update);
    });
    // Etc...
}

// Connect to a channel chat.
connect(1, 2, 'jnoh986');

FAQs

Package last updated on 10 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.