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

@magnet-fe/magnet-im-lib

v1.1.0

Published

Magnet shared IM library, RongCloud edition

Downloads

4

Readme

使用

  • 访问融云 Web SDK 开发指南
  • 根据文档添加 2.3.3 版 SDK 到项目中,如需使用新版本,需要更新本项目内的 .d.ts 文件
  • 安装 @private/magnet-im-lib 并使用
  • 当使用 Emoji 时, 需要引入融云 Emoji 库 文档
  • 官方没有提供 Emoji 的 .d.ts 文件,当前版本 vendor/RongEmoji-xx.d.ts 基于 2.2.7 版本编写,使用新版本时需要更新此文件

开发

初始化

import { MagnetIM, MessageTypes } from '@private/magnet-im-lib';

// 配置参数参考文档,包含认证信息和收消息的 Listener
// 可以通过返回 Promise 实现同步的连接后(onConnect)后执行特定操作, 例如:
function initSomething () {
    return new Promise((resolve, reject) => {
        new MagnetIM({
            ...你的配置...,
            Listener: {
                ...其他Listener...,
                onConnect (userInfo) {
                    // 做点你想做的事
                    resolve(userInfo);
                }
            }
        });
    });
}

await initSomething();
await joinSomeGroup();

发送消息

let message = new RongIMLib.TextMessage({
    content: 'Hello World',
    user: userInfoVariable
});

let msgResponse = await MagneIM.instance.sendMessage({
    conversationType: RongIMLib.ConversationType.CHATROOM,
    targetID: 'abcdef'.
    messageContent: message,
    onBeforeListener (messageId) {
        // 这里会在消息发送之前会触发,可以自己制造一个假数据放在 UI 上展示
    }
});

// 消息发送成功后, msgResponse 是服务端返回的消息对象,可以用于替换上面的假数据,
// 需要做异常处理,可能会遇到发送失败的情况。

发送磁场自定义的消息类型

具体可用消息类型参考文档

import { MessageTypes } from '@private/magnet-im-lib'

let message = new MessageTypes.QuestionMessage({
    type: MessageTypes.IQuestionMessageContentType.QuestionCreate // 提问,
    question: '你好吗? 我不好'
    user: // 在这里传入用户信息, 见文档内的 types/BaseMessage 中的 IUserInfo
})

/**
 * 创建消息时应包含的字段可以参考文档的 types/MagnetMessage 中的 I**MessageContent 。
 * 除了只接收不发送的 NotificationMessage 以外,所有的消息结构都是 I**MessageContent extends IBaseMessageContent ,
 * 每条消息都应该包含 User 信息。
 */