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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@houwx/rtc-client

v0.1.0

Published

SDK based on browser WebRTC API encapsulation for building video call applications

Downloads

1

Readme

RTCClient()

Syntax

new RTCClient(options)

Parameters

options

  • configuration: RTCConfiguration
  • constraints: MediaStreamConstraints
  • socketConfig:
    • host: 域名或者ip
    • port?: 端口
import RTCClient from 'rtc-client';

const host = 'https://127.0.0.1'
const port = 3000

const rtc = new RTCClient({
  configuration: {
    iceServers: [
      {
        urls: `turn:stun.l.google.com:19302`,
        username: "webrtc",
        credential: "turnserver",
      },
    ],
  },
  constraints: {
    audio: true,
    video: true
  },
  socketConfig: {
    host,
    port,
  }
})

Instance methods

on(type: string, listener: function): void

绑定event事件

off(type: string, listener: function): void

解除绑定event事件

shareDisplayMedia(): Promise

开启视频共享

cancelShareDisplayMedia(): void

取消视频共享

join(data: { username: string, roomname: string }): void

加入房间

leave(): void

离开房间

getDevicesInfoList(): Promise<MediaDeviceInfo[]>

获取设备列表

getVideoDeviceInfo(): Promise

获取当前使用的视频输入设备信息

getAudioDeviceInfo(): Promise

获取当前使用的音频输入设备信息

channelSendMesage(): void

使用RTCDataChannel数据通道发送消息

replaceTrack(deviceId: string, kind: 'video' | 'audio'): void

切换设备媒体轨道

replaceVideoTrack(deviceId: string): void

切换视频媒体轨道

replaceAudioTrack(deviceId: string): void

切换音频媒体轨道

deviceSwitch(state: boolean, kind: 'video' | 'audio'): void

切换设备状态

disableAudio(): void

禁用麦克风

enableAudio(): void

启用麦克风

disableVideo(): void

禁用摄像头

enableVideo(): void

启用摄像头

getLocalStream(): Promise

获取本地媒体流

getDisplayStream(): Promise

获取共享屏幕媒体流

close(): void

关闭rtcclient实例

Events

connectorInfoListChange

当与连接的客户端列表发生改变或者更新时触发

rtc.on('connectorInfoListChange', (data) => {
  console.log('onConnectorInfoListChange', data);
})

displayStreamChange

当共享屏幕媒体流发生变化时触发

rtc.on('displayStreamChange', async (stream) => {
  displayStream = stream
})

localStreamChange

当本地媒体流发生变化时触发

rtc.on('localStreamChange', async (stream) => {
  localStream = stream
})

message

当RTCDataChannel数据通道接收到数据时触发

rtc.on('message', async (message: MessageItem) =>{
  message.isSelf = false
  messageList.push(message)
  console.log(message);
})