Skip to content

nim.tool.NIMTool

Zvicii edited this page Feb 10, 2023 · 6 revisions

Class: NIMTool

nim/tool.NIMTool

Hierarchy

Table of contents

Methods

Properties

Constructors

Methods

eventNames

eventNames(): never[]

Return an array listing the events for which the emitter has registered listeners.

Returns

never[]

Inherited from

EventEmitter.eventNames

Defined in

node_modules/eventemitter3/index.d.ts:15


listeners

listeners<T>(event): (...args: ArgumentMap<NIMToolEvents>[Extract<T, never>]) => void[]

Return the listeners registered for a given event.

Type parameters

Name Type
T extends never

Parameters

Name Type
event T

Returns

(...args: ArgumentMap<NIMToolEvents>[Extract<T, never>]) => void[]

Inherited from

EventEmitter.listeners

Defined in

node_modules/eventemitter3/index.d.ts:20


listenerCount

listenerCount(event): number

Return the number of listeners listening to a given event.

Parameters

Name Type
event never

Returns

number

Inherited from

EventEmitter.listenerCount

Defined in

node_modules/eventemitter3/index.d.ts:27


emit

emit<T>(event, ...args): boolean

Calls each of the listeners registered for a given event.

Type parameters

Name Type
T extends never

Parameters

Name Type
event T
...args ArgumentMap<NIMToolEvents>[Extract<T, never>]

Returns

boolean

Inherited from

EventEmitter.emit

Defined in

node_modules/eventemitter3/index.d.ts:32


on

on<T>(event, fn, context?): NIMTool

Add a listener for a given event.

Type parameters

Name Type
T extends never

Parameters

Name Type
event T
fn (...args: ArgumentMap<NIMToolEvents>[Extract<T, never>]) => void
context? any

Returns

NIMTool

Inherited from

EventEmitter.on

Defined in

node_modules/eventemitter3/index.d.ts:40


addListener

addListener<T>(event, fn, context?): NIMTool

Type parameters

Name Type
T extends never

Parameters

Name Type
event T
fn (...args: ArgumentMap<NIMToolEvents>[Extract<T, never>]) => void
context? any

Returns

NIMTool

Inherited from

EventEmitter.addListener

Defined in

node_modules/eventemitter3/index.d.ts:45


once

once<T>(event, fn, context?): NIMTool

Add a one-time listener for a given event.

Type parameters

Name Type
T extends never

Parameters

Name Type
event T
fn (...args: ArgumentMap<NIMToolEvents>[Extract<T, never>]) => void
context? any

Returns

NIMTool

Inherited from

EventEmitter.once

Defined in

node_modules/eventemitter3/index.d.ts:54


removeListener

removeListener<T>(event, fn?, context?, once?): NIMTool

Remove the listeners of a given event.

Type parameters

Name Type
T extends never

Parameters

Name Type
event T
fn? (...args: ArgumentMap<NIMToolEvents>[Extract<T, never>]) => void
context? any
once? boolean

Returns

NIMTool

Inherited from

EventEmitter.removeListener

Defined in

node_modules/eventemitter3/index.d.ts:63


off

off<T>(event, fn?, context?, once?): NIMTool

Type parameters

Name Type
T extends never

Parameters

Name Type
event T
fn? (...args: ArgumentMap<NIMToolEvents>[Extract<T, never>]) => void
context? any
once? boolean

Returns

NIMTool

Inherited from

EventEmitter.off

Defined in

node_modules/eventemitter3/index.d.ts:69


removeAllListeners

removeAllListeners(event?): NIMTool

Remove all listeners, or those of the specified event.

Parameters

Name Type
event? undefined

Returns

NIMTool

Inherited from

EventEmitter.removeAllListeners

Defined in

node_modules/eventemitter3/index.d.ts:79


initEventHandlers

initEventHandlers(): void

注册全局回调

Returns

void

Defined in

ts/nim/tool.ts:16


getUserAppdataDir

getUserAppdataDir(appAccount): string

获取SDK里app account对应的app data目录(各个帐号拥有独立的目录,其父目录相同)

Parameters

Name Type
appAccount string

Returns

string

std::string 返回的目录路径(UTF8)

Defined in

ts/nim/tool.ts:24


getSpecificAppdataDir

getSpecificAppdataDir(appAccount, appdataType): string

获取SDK里app account对应的具体类型的app data目录(如图片消息文件存放目录,语音消息文件存放目录等),需要调用nim_free_buf(void *data)释放内存

Parameters

Name Type
appAccount string
appdataType NIMAppDataType

Returns

string

std::string返回的目录路径(目录可能未生成,需要app自行判断是否已生成)

Defined in

ts/nim/tool.ts:33


getLocalAppdataDir

getLocalAppdataDir(): string

获取本地存储路径

Returns

string

std::string 返回的目录路径(UTF8)

Defined in

ts/nim/tool.ts:40


getCurModuleDir

getCurModuleDir(): string

获取安装目录(SDK DLL所在的当前目录)

Returns

string

std::string 返回的目录路径(UTF8)

Defined in

ts/nim/tool.ts:47


getMd5

getMd5(input): string

计算md5

Parameters

Name Type Description
input string 需要计算md5的内容

Returns

string

std::string 返回的md5

Defined in

ts/nim/tool.ts:55


getFileMd5

getFileMd5(filePath): string

计算文件的md5

Parameters

Name Type
filePath string

Returns

string

std::string 返回的md5

Defined in

ts/nim/tool.ts:63


getUuid

getUuid(): string

生成UUID

Returns

string

std::string 返回的UUID

Defined in

ts/nim/tool.ts:70


getAudioTextAsync

getAudioTextAsync(audioInfo, cb, jsonExtension): Promise<null | [NIMResCode, string]>

语音转文字

Note

200:成功
403:没有权限
414:参数错误
500:未知错误
6101:语音转码解析失败
6102:语音时长过长(超过60s
6103:服务不可用
6104:audioUrl不合法

Parameters

Name Type Description
audioInfo AudioInfo -
cb null | GetAudioTextCallback 语音转文字回调
jsonExtension string json扩展参数(备用,目前不需要)

Returns

Promise<null | [NIMResCode, string]>

boolean 检查参数如果不符合要求则返回失败

Defined in

ts/nim/tool.ts:91


filterClientAntispam

filterClientAntispam(text, replaceString, libName, cb): Promise<[boolean, NIMResCode, string]>

客户端本地反垃圾

Note

回调函数ret
1:敏感词已被替换;
2:含有敏感词不允许发送;
3:需要将内容设置在消息结构的反垃圾字段里,由服务器过滤

Parameters

Name Type Description
text string 文本内容,UTF-8
replaceString string -
libName string -
cb null | FilterClientAntispamCallback -

Returns

Promise<[boolean, NIMResCode, string]>

Defined in

ts/nim/tool.ts:124

Properties

tool

tool: NIMToolAPI

Defined in

ts/nim/tool.ts:9

Constructors

constructor

new NIMTool()

Overrides

EventEmitter<NIMToolEvents&gt;.constructor

Defined in

ts/nim/tool.ts:10

Clone this wiki locally