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

wxh-node-cmpp

v4.0.1

Published

An implementation for cmpp v2.0 / v3.0 protocol using Node.js.

Downloads

1

Readme

cmpp

cmpp v2.0 / v3.0 的实现方案

Usage

const Client = require('cmpp');

const client = new Client({
  host: '127.0.0.1',
  port: 7890,
  serviceId: 'serviceName',
  srcId: '10xxxxxx',
  heartbeatMaxAttempts: 3,
  heartbeatInterval: 3 * 60 * 1000,
  heartbeatTimeout: 60 * 1000,
  timeout: 30 * 1000,
  mobilesPerSecond: 200,
  version: 0x20, // or 0x30,
});

// 每秒的发送量
client.on('mobile_count', (sendingMobileCount) => {});

// 设置「上行回调」处理方法, 同步异步均支持
// 方法执行完成后发送 CMPP_DELIVER_RESP, 异常失败时 Result = 7 (业务代码错)
client.setReceive(async(body = {}) => {
  // console.log(body);
});

// 设置「下行回调」处理方法,同步异步均支持
// 方法执行完成后发送 CMPP_DELIVER_RESP, 异常失败时 Result = 7 (业务代码错)
client.setDeliver(async(body = {}) => {
  // console.log(body);
});

// 报错信息
client.on('error', (err) => {});

// 请求超时, command 为命令, 比如 CMPP_CONNECT
client.on('timeout', (command) => {});

client.on('terminated', (message) => {
  // 连接主动断开和心跳停止断开
  // undefined or 'heartbeat'
  console.log(message);
});

const SourceAddr = '100100'; // 源地址,此处为 SP_Id,即 SP 的企业代码
const SharedSecret = 'password'; // 授权密码
client.connect(SourceAddr, SharedSecret).catch(err => {});

// client.send(mobile, content, extendCode); // 扩展码可不填
client.send('1358888xxxx', '【签名】这里是内容', '1234');

// 批量发送, 上限 100 个号码
// client.sendGroup(['1358888xxxx', '1368888xxxx'], '【签名】这里是内容', '1234');

// 断开连接
client.disconnect()

备注

v0.x.x 基于 @nbcat 实现的 nb-cmpp-2 项目重写.