feat: 将 NIM Gateway 从单实例 node-nim SDK 迁移到 多实例 nim.js SDK,支持多实例 #264
Merged
liuzhq1986 merged 1 commit intonetease-youdao:mainfrom Mar 4, 2026
Merged
feat: 将 NIM Gateway 从单实例 node-nim SDK 迁移到 多实例 nim.js SDK,支持多实例 #264liuzhq1986 merged 1 commit intonetease-youdao:mainfrom
liuzhq1986 merged 1 commit intonetease-youdao:mainfrom
Conversation
This was referenced Mar 5, 2026
mammut001
pushed a commit
to mammut001/LobsterAI
that referenced
this pull request
Mar 11, 2026
feat: 将 NIM Gateway 从单实例 node-nim SDK 迁移到 多实例 nim.js SDK,支持多实例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更概要
将 NIM Gateway 的底层 IM SDK 从
node-nim(C++ 原生模块)迁移到nim.js(Web SDK Node.js 版),解决了 node-nim 单例限制导致无法同时运行多个 NIM 实例的问题。变更动机
node-nim是基于 C++ 的原生模块,存在以下问题:nim.js(Web SDK Node.js 版 v10.9.76)支持new NIM()多实例创建,彻底解决上述问题。主要变更
新增文件
src/libs/nim.js— NIM Web SDK Node.js 版(v10.9.76),支持 V2 消息和会话模块src/libs/nim/*.d.ts— 完整的 TypeScript 类型定义(40 个声明文件)nimGateway.ts 改造
require('node-nim')+new V2NIMClient()+client.init()→new NIM({appkey, ...})client.getLoginService()→v2Client.V2NIMLoginService(直接属性访问)receiveMessages→onReceiveMessages,loginStatus→onLoginStatus等(加on前缀)client.uninit()→V2NIMLoginService.logout()loginService/messageService/messageCreator/conversationIdUtil字段,统一通过v2Client访问v2Client从any改为V2NIM类型测试验证