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

janus-connector

v1.1.0

Published

A Vue component based on janus-manager library to easy to development.

Downloads

3

Readme

janus-connector

基于 janus-manger 的Vue组件,用于快速构建janus通讯应用。

Usage

安装

npm install janus-manager janus-connector --save

使用

import JanusConnector from "janus-connector";

export default {
  components: {
    JanusConnector,
  },
  data() {
    return {
      loading: true,
      calling: false,
      serverConfig: {
        server: [
          "https://janus-server/janus",
          "wss://janus-server",
        ],
        // 轮询超时时间(一般应大于服务端超时时间),默认60s,可不设置
        // longPollTimeout: 60000,
      },
      sipConfig: {
        proxy: "sip:xxx.xxx.xxx.xxx:port", // SIP服务器
        username: "sip:[email protected]:port", // SIP身份
        authuser: "authuser", // SIP号
        secret: "password",
        displayname: "", // 显示名称
      },

      phoneNumber: "",
    };
  },
  computed: {
    callNumber() {
      return `sip:${this.phoneNumber}@xxx.xxx.xxx.xxx:port`;
    },
  },
  methods: {
    loadHandler({ handler }) {
      this.loading = false;
      this.handler = handler;
      // 加载完成,之后可进行电话拨打
    },
    callHandler() {
      if(this.calling){
        this.hangupHandler();
      }else {
        this.handler.makeCall(this.callNumber).then(() => {
          this.calling = true;
        });
      }
    },
    hangupHandler() {
      this.calling = false;
      this.handler.hangup();
    },
    // 监听处理事件
    messageHandler({ event, msg }) {
      // console.log("-----", event, "-------", msg);
      if (event === "accepted") {
        // accepted
      }
    },
    incomingcallHandler({ jsep, username }) {
      // username incoming call
      console.log('incoming call: ', username);

      // answer
      this.handler.answerCall(jsep, { audio: true });

      // decline
      // this.handler.declineCall();
    },
    // 处理发送键盘拨号方法
    sendDtmf(tones) {
      this.handler.sendDtmf({ tones });
    },
    // 处理错误事件
    errorHandler({ type, error }) {
      if (type === "timeout") {
        // 超时错误
        console.error(error.message);
        // alert(type + ": " + error.message);
      } else if (type === "hangup") {
        // 异常挂断
        this.calling = true;
      }
    },
  },
};
<template>
  <div>
    <JanusConnector
      :serverConfig="serverConfig"
      :sipConfig="sipConfig"
      @load="loadHandler"
      @hangup="hangupHandler"
      @message="messageHandler"
      @incomingcall="incomingcallHandler"
      @error="errorHandler"
    >
      <span v-if="loading">loading...</span>
      <input v-model="phoneNumber" />
      <button @click="callHandler">
        {{ calling ? "挂断" : "拨打" }}
      </button>
    </JanusConnector>
  </div>
</template>

说明

  • 轮询设置 通过longPollTimeout字段设置轮询超时时间,必须设置大于服务端的超时时间,默认为6000ms

  • JanusConnector组件属性与事件

    • 方法:
      • serverConfig:配置serverlongPollTimeout等配置
      • sipConfig:配置proxyusernameauthusersecretdisplayname等信息
    • 事件:
      • load:与服务端建立连接,并注册到sip server成功后触发,回调中可获取到 {handler, manager}对象,handler可用于拨打或挂断电话操作
      • hangup:监听服务端挂断事件,挂断逻辑已在组件中处理,调用者只需处理自定义业务逻辑即可
      • incomingcall:监听呼入事件,回调中可获取 { jsep, username }对象,之后通过handler可用于接听或挂断电话操作
      • message: 监听所有类型事件,包括registeringregisteredregistration_failedcallingincomingcallprogressacceptedhangup 等事件
      • error:处理错误事件,包含错误类型timeoutconnectregistration_failed