UNPKG

node-nim

Version:

NetEase IM nodejs wrapper based on NetEase IM C++ SDK

66 lines 2.24 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.NIMPlugin = void 0; const eventemitter3_1 = require("eventemitter3"); const loader_1 = __importDefault(require("../loader")); class NIMPlugin extends eventemitter3_1.EventEmitter { constructor() { super(); this.plugin = new loader_1.default.NIMPluginIn({ emit: this.emit.bind(this) }); } /** 注册全局回调 */ initEventHandlers() { return this.plugin.InitEventHandlers(); } /** 异步获取聊天室登录信息 * @param roomId 聊天室ID * @param cb 回调函数 * @param ext json扩展参数(备用,目前不需要) * @return void 无返回值 * @note * <pre> * 200:成功 * 414:参数错误 * 404:聊天室不存在 * 403:不允许进入该聊天室 * 415:服务不可用,没有聊天室服务器可分配 * 13003:在黑名单中 * </pre> */ chatRoomRequestEnterAsync(roomId, cb, ext) { return new Promise((resolve) => { this.plugin.ChatRoomRequestEnterAsync(roomId, (rescode, result) => { if (cb) { cb(rescode, result); } resolve([rescode, result]); }, ext); }); } /** 异步获取圈组link地址 * @param[in] ip_version ip协议, 0:ipv4, 1:ipv6, 2:all * @param[in] callback 回调函数 * @param[in] jsonExtension json扩展参数(备用,目前不需要) * @return void 无返回值 * @note * <pre> * 200:成功 * 414:参数错误 * </pre> */ qchatRequestLinkAddress(ip_version, cb, ext) { return new Promise((resolve) => { this.plugin.QChatRequestLinkAddress(ip_version, (rescode, result) => { if (cb) { cb(rescode, result); } resolve([rescode, result]); }, ext); }); } } exports.NIMPlugin = NIMPlugin; //# sourceMappingURL=plugin.js.map