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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sim-js-sdk

v1.0.1

Published

Readme

讯盟即时通讯IM SDK

简介

为了顺应行业数字化转型的趋势,讯盟将高并发、高可靠的即时通信能力进行开放,您可以轻易地根据提供的 SDK 将即时通信功能集成到您的应用中,来满足您业务的各种需求。

针对开发者的不同阶段需求及不同场景,即时通信团队提供了一套Web的SDK组件。

利用这个组件,开发者可以简单快捷地构建高可靠且稳定的即时通信产品

使用

创建 SDK 实例

import SIM from 'sim-js-sdk'

// 创建 SDK 实例
// 只能创建一个实例
const sim = SIM.create()

// 设置日志级别为开发级别
sim.setLogLevel(SIM.LOG_LEVEL.DEVELOP) 

其他详细的日志级别介绍,请参看 LOG_LEVEL

绑定事件

sim.on(SIM.EVENTS.MESSAGE_RECEIVED, function(messages) {
  // 收到推送的单聊、群聊、群操作、系统等新消息,可以遍历 messages 消息列表
})

sim.on(SIM.EVENTS.MESSAGE_REVOKED, function(messages) {
  // 收到消息被撤回的通知,可以遍历 messages 查看具体的被撤回消息列表
})

sim.on(SIM.EVENTS.NET_STATE_CHANGE, function(state) {
  // 网络状态发生变化
  // state 为当前的网络状态
  // SIM.TYPES.NET_STATE_CONNECTED 网络已连接
  // SIM.TYPES.NET_STATE_DISCONNECTED 网络已断开
})

sim.on(SIM.EVENTS.KICK_OUT, function(type) {
  // 收到消息被撤回的通知,可以遍历 messages 查看具体的被撤回消息列表
  // type 为被踢的类型
  // SIM.TYPES.KICK_OUT_BY_USER 多实例登录被踢,在其他地方登录了此账号
  // SIM.TYPES.KICK_OUT_BY_MOBILE 多终端登录被踢,在其他端主动退出了web端的登录
  // SIM.TYPES.KICK_OUT_BY_CONNECTION 由于其他原因,导致消息通道断开被踢
})

sim.on(SIM.EVENTS.NOT_LOGIN, function() {
  // 由于token过期等原因,导致服务端返回未登录
  // 此时需要重新获取用户的登录信息,调用 login 接口进行登录
})

登录

用户只有在登录完成之后,才能收发消息,获取会话等操作

注意
登录成功之后,不要重复登录


// 要登录的用户信息,需要从服务端拿
const options = {
  userId: '123', // 用户id
  userName: '小一', // 用户名称
  userSig: 'a03defe09fae0931' // 用户登录密钥
}

sim.login(options).then(function() {
  console.log('登录成功')
}).catch(function(error) {
  console.warn('登录失败:', error) // 登录失败的相关信息
})

登出

通常在切换账号或者要退出 IM 时调用,会清除登录状态与数据

sim.logout().then(function() {
  console.log('登出成功')
}).catch(function(error) {
  console.warn('登出失败:', error)
})