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

wild-rtc

v0.1.0

Published

webrtc with wilddog support

Downloads

2

Readme

lib-js-wildRTC

使用 Wilddog 实现的实时音视频聊天库.可使用 test.html 来测试。

引入WildRTC SDK

使用gulp搭建测试环境

下载代码到本地,并进入lib-js-wildRTC目录

git clone https://github.com/WildDogTeam/lib-js-wildRTC.git

安装 gulp,在ubuntu下使用命令

sudo npm install gulp

安装依赖

sudo npm install uglify-js
sudo npm install gulp-uglify
sudo npm install gulp-browserify
sudo npm install gulp-rename
sudo npm install gulp-connect
sudo npm install wild-peerconnection

打包成一个 js。打包后会在 lib 下生成 WildRTC.js。

gulp build

建立测试环境

gulp test

这会在本地 https://localhost:8080 建立一个 webserver,可以访问 test.html 或用户自己建立的网页。

使用 WildRTC

创建引用

要使用 WildRTC,必须先创建 WildDog 引用并登录:

var ref = new Wilddog("https://<appId>.wilddogio.com/");
ref.authAnonymously();
ref.onAuth(function(auth) {
    if (auth != null) {
        var rtc = new WildRTC(ref);
    }
}

加入会话

创建 WildRTC 引用之后,就可以通过join(callback) 进入会话:

wildRTC.join(callback(err));

监听远端媒体流

可以使用on(type,callback,cancelCallback)的事件监听来获取远端的媒体流。

wildRTC.on("stream_added",function(WildStream){
	console.log(WildStream.getId());	//结果会在 console 中打印出远端 WildStream 的 Id
})

回调函数的参数是一个 WildStream 对象类型,调用它的getStream()函数得到媒体流。上边这个例子中,stream_added这个事件会在每次收到远端 WildStream 时被触发。

同时,我们还提供stream_removed事件,用来监听远端停止发送 WildStream 的事件,并在回调函数中提供停止发送的远端WildStream 。

获取本地媒体流

我们提供getLocalStream(options,callback,cancelCallback)来获取本地媒体流。

wildRTC.getLocalStream(options,function(WildStream){
	console.log(WildStream.getId());	//结果会在 console 中打印出远端WildStream的Id
}, function(err){
	console.log(err);			//打印错误日志。
})

options 内容为设置获取媒体流的规格,为JSON 字符串。可以传入{"video":true|false, "audio":true|false}来设置videoaudio的开启情况。回调函数中的参数为 WildStream 对象类型。

向远端发送媒体流

拿到WildStream后,通过addStream(wildStream)向远端其他用户发送媒体流。

wildRTC.addStream(wildStream);

媒体流与页面绑定

WildStream对象提供bindToDOM(elementId)快速将媒体流与页面绑定。

wildStream.bindToDOM('self_view');

更多详细接口见 docs 下的API文档。