UNPKG

@fork-anyone/node-nim

Version:

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

36 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NIMPassThroughProxy = void 0; const eventemitter3_1 = require("eventemitter3"); class NIMPassThroughProxy extends eventemitter3_1.EventEmitter { constructor(sdk) { super(); this.proxy = new sdk.NIMPassThroughProxy({ emit: this.emit.bind(this) }); } /** 注册全局回调 */ initEventHandlers() { return this.proxy.InitEventHandlers(); } /** 发送一个透传 HTTP 请求 * @param host 要发送的 HTTP 请求 Host 地址 * @param path URL 中除了 Host 的 Path * @param method 要发送的 HTTP 请求方式 * @param header 要发送的 HTTP 请求 Header 内容 * @param body 要发送的 HTTP 请求 Body 内容 * @param jsonExtension 拓展字段,暂时无用 * @param cb 发送请求后的数据回调函数 * @return void 无返回值 */ sendHttpRequest(host, path, method, headers, body, jsonExtension, cb) { return new Promise((resolve) => { this.proxy.SendHttpRequest(host, path, method, headers, body, jsonExtension !== null && jsonExtension !== void 0 ? jsonExtension : '', (rescode, header, body, jsonExtension) => { if (cb) { cb(rescode, header, body, jsonExtension !== null && jsonExtension !== void 0 ? jsonExtension : ''); } resolve([rescode, header, body, jsonExtension]); }); }); } } exports.NIMPassThroughProxy = NIMPassThroughProxy; //# sourceMappingURL=pass_through_proxy.js.map