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

easemob-im-server

v1.0.0

Published

node easemob-im sdk

Downloads

1

Readme

Install 安装

use npm install

使用 npm 安装

npm install node-easemob-im-server

download from github

从 github下载

Introduce 模块说明

该模块支付部分环信im接口,详情参考环信官网

Sample example 使用说明

init Client 初始化客户端

/**
 * 初始化客户端
 * @param {object} params 
 * params
 * @param {String} client_id 应用id
 * @param {String} client_secret 应用密钥
 * @param {String} org_name 租户名
 * @param {String} app_name 应用名
 * @param {String} host 域名
 * @returns 
 */
const params = {
    client_id:"",
    client_secret:"",
    org_name:"",
    app_name:"",
    host:""
};
const client = require('../index').initClient(params);

注册单个用户(授权)

/**
 * 注册单个用户(授权)
 * @param {object} params 
 * params
 * @param {String} username 用户ID 
 * @param {String} password 登录密码,默认为000000
 * @param {String} nickname 昵称
 */
let createUser = () => {
    client.createUser({
        username:"penguin",
        nickname:"企鹅"
    })
    .then((data) => {
        console.log(data);
    })
}
// createUser()

设置推送昵称,与创建时无关

/**
 * 设置推送昵称,与创建时无关
 * @param {object} params 
 * params
 * @param {String} username 用户ID 
 * @param {String} nickname 昵称
 */
let setNickName = () => {
    client.setNickName({
        username:"penguin",
        nickname:"22xxs"
    })
    .then((data) => {
        console.log(data);
    })
}

// setNickName()

发送消息

/**
 * 发送消息
 * @param {object} params 
 * params
 * @param {String} target_type 发送的目标类型;users:给用户发消息,chatgroups:给群发消息,chatrooms:给聊天室发消息 
 * @param {Array} target 发送的目标,使用id数组
 * @param {Object} msg 消息对象
 * 
 * msg 
 * @param {String} type 消息类型;txt:文本消息,img:图片消息,loc:位置消息,audio:语音消息,video:视频消息,file:文件消息
 * 
 * type为txt时msg增加参数
 * @param {String} msg 消息内容
 * 
 * type为img、audio时msg增加参数
 * @param {String} url 成功上传文件返回的UUID
 * 
 */

//发送文字
let sendMsg = () => {
    client.sendMsg({
        target_type:"users",
        target:["penguin"],
        msg:{
            type:"txt",
            msg:"123"
        }
        
    })
    .then((data) => {
        console.log(data);
    })
}
// sendMsg()

//发送图片
let sendMsg2 = () => {
    client.sendMsg({
        target_type:"users",
        target:["penguin"],
        msg:{
            type:"img",
            url:`${__dirname}/2.png`
        }
    })
    .then((data) => {
        console.log(data);
    })
    .catch((err) => {
        console.log(err);
    })
}
// setTimeout(() => {
//     sendMsg2()
// },2000)

//发送语音
let sendMsg3 = () => {
    client.sendMsg({
        target_type:"users",
        target:["penguin"],
        msg:{
            type:"audio",
            url:`${__dirname}/2.mp3`
        }
        
    })
    .then((data) => {
        console.log(data);
    })
}
// setTimeout(() => {
//     sendMsg3()
// },2000)

初始化发送准备,图片、语音需要先进行上传

/**
 * 初始化发送准备,图片、语音需要先进行上传
 * @param {object} params 
 * params
 * @param {String} type 消息类型;txt:文本消息,img:图片消息,loc:位置消息,audio:语音消息,video:视频消息,file:文件消息
 * @param {String} url 文件地址,能被应用访问到的地址
 */
let upload = () => {
    client.initSend({
        type:"img",
        url:`${__dirname}/2.png`
    })
    .then((data) => {
        console.log("data");
        console.log(data);
    })
}

// setTimeout(() => {
//     upload()
// },2000)