npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chatroom-web-sdk

v1.0.0

Published

```sh npm install -S chatroom-web ```

Readme

chatroom-web

安装

npm install -S chatroom-web

如何使用

import * as uuid from "uuid";
// 引用 SDK
import { SimpleSDK } from "chatroom-sdk/SimpleSDK";
// 引用麦位管理
import { SeatManager } from 'chatroom-sdk/SetaManager';
// 引用麦位类型及常数
import * as seatTypes from 'chatroom-sdk/SeatTypes';

// SDK, config 配置
const config = {
    appId = 0,       // 申请账号的 app id
    signKey = "",    // 申请账号的 sign key
    isTestEnv = true // 是否使用测试环境
};
const userId = uuid.v4();
const userId2 = uuid.v4();
const token = "";

// SDK, 构建新 SDK 对象
const simpleSDK = new SimpleSDK({ appId: config.appId, isTestEnv: config.isTestEnv });
// 麦位, 构建新麦位管理对象
const manager = new SeatManager({ userId: userId });

// SDK, 设置用户名
simpleSDK.setConfig({ idName: userId });

// 麦位, 设置麦位状态更新回调
manager.onSeatsCenterChange = (seatsCenter, isRemote) => {
    if (isRemote) {
        console.log("update from remote");
    } else {
        console.log("update from local");
    }
    // 麦位, 美化麦位状态, 方便调试和查看
    const res = manager.beautiful(seatsCenter);
    console.log(res);

    // 麦位, 获取当前用户麦位状态
    const currSeatStatus = manager.getCurrSeatStatus();
    console.log(currSeatStatus);

    if (!isRemote) {
        const content = JSON.stringify(seatsCenter);
        // 麦位, 当本地更新时, 用可靠消息发送新的麦位状态
        return simpleSDK.sendReliableMessage(manager.messageType, JSON.stringify(content));
    } else {
        // 麦位, 返回空 resolve 至回调
        return Promise.resolve(0);
    }
}

// SDK, 添加可靠消息回调
simpleSDK.addOnRecvReliableMessage((type, seq, data) => {
    if (!data) return;
    const seatsCenter = JSON.parse(data as string);
    if (!seatsCenter[seatTypes.SEATS_Status_KEY]) return;
    manager.updateSeatsCenter(seatsCenter);
});
// SDK, 登录房间
await simpleSDK.login({ roomId, token });

const useSeatControls = async () => {
    // 上麦
    await manager.takeSeat(1);
    // 下麦
    await manager.leaveSeat();
    console.log(manager.getCurrSeatStatus());

    // 锁麦
    await manager.lockSeat(0);
    // 解锁麦位
    await manager.unlockSeat(0);

    // 关闭麦位
    await manager.closeSeat(0);
    // 打开麦位
    await manager.openSeat(0);

    // 静音麦位
    await manager.muteSeat(0);
    // 取消静音
    await manager.unmuteSeat(0);

    // 静音所有麦位
    await manager.muteAllSeat();
    // 取消所有麦位静音
    await manager.unmuteAllSeat();

    // 抱人上麦
    await manager.pickupSeat({ [seatTypes.USER_ID_KEY]: userId2, [seatTypes.USER_NAME_KEY]: userId2 }, 2);
    // 抱人下麦
    await manager.pickupDownSeat({ [seatTypes.USER_ID_KEY]: userId2, [seatTypes.USER_NAME_KEY]: userId2 }, 2);
};

useSeatControls();

WebRTC SDK 方法的使用

  • SimpleSDK 内置了一些常用方法
    • login
    • setConfig
    • getRoomList
    • startPreview
    • stopPreview
    • startPublish
    • stopPublish
    • playStream
    • playStreams
    • stopPlayStream
    • stopPlayStreams
    • sendReliableMessage
    • addOnRecvReliableMessage
  • 其他 SDK 方法可通过 simpleSDK.client 实例获取,具体可参考文档 https://doc-zh.zego.im/zh/1806.html

注意事项

  • 当没用户在房间的时候,房间将会销毁,麦位状态将会重置
  • 必须已经登录才可发送消息
  • 移动端的播放麦位,必须渲染在页面上,并且触发点击才可自动播放
  • 麦位管理只提供麦位状态和麦位操作,具体业务推拉流逻辑需要自行添加开发