Skip to content

nim.nos.NIMNOS

Zvicii edited this page Feb 10, 2023 · 7 revisions

Class: NIMNOS

nim/nos.NIMNOS

Hierarchy

Table of contents

Methods

Properties

Constructors

Methods

eventNames

eventNames(): keyof NIMNOSEvents[]

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

Returns

keyof NIMNOSEvents[]

Inherited from

EventEmitter.eventNames

Defined in

node_modules/eventemitter3/index.d.ts:15


listeners

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

Return the listeners registered for a given event.

Type parameters

Name Type
T extends keyof NIMNOSEvents

Parameters

Name Type
event T

Returns

(...args: ArgumentMap<NIMNOSEvents>[Extract<T, keyof NIMNOSEvents>]) => 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 keyof NIMNOSEvents

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 keyof NIMNOSEvents

Parameters

Name Type
event T
...args ArgumentMap<NIMNOSEvents>[Extract<T, keyof NIMNOSEvents>]

Returns

boolean

Inherited from

EventEmitter.emit

Defined in

node_modules/eventemitter3/index.d.ts:32


on

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

Add a listener for a given event.

Type parameters

Name Type
T extends keyof NIMNOSEvents

Parameters

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

Returns

NIMNOS

Inherited from

EventEmitter.on

Defined in

node_modules/eventemitter3/index.d.ts:40


addListener

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

Type parameters

Name Type
T extends keyof NIMNOSEvents

Parameters

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

Returns

NIMNOS

Inherited from

EventEmitter.addListener

Defined in

node_modules/eventemitter3/index.d.ts:45


once

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

Add a one-time listener for a given event.

Type parameters

Name Type
T extends keyof NIMNOSEvents

Parameters

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

Returns

NIMNOS

Inherited from

EventEmitter.once

Defined in

node_modules/eventemitter3/index.d.ts:54


removeListener

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

Remove the listeners of a given event.

Type parameters

Name Type
T extends keyof NIMNOSEvents

Parameters

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

Returns

NIMNOS

Inherited from

EventEmitter.removeListener

Defined in

node_modules/eventemitter3/index.d.ts:63


off

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

Type parameters

Name Type
T extends keyof NIMNOSEvents

Parameters

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

Returns

NIMNOS

Inherited from

EventEmitter.off

Defined in

node_modules/eventemitter3/index.d.ts:69


removeAllListeners

removeAllListeners(event?): NIMNOS

Remove all listeners, or those of the specified event.

Parameters

Name Type
event? keyof NIMNOSEvents

Returns

NIMNOS

Inherited from

EventEmitter.removeAllListeners

Defined in

node_modules/eventemitter3/index.d.ts:79


initEventHandlers

initEventHandlers(): void

注册全局回调

Returns

void

Defined in

ts/nim/nos.ts:38


initConfig

initConfig(param, cb): Promise<[InitNosResult]>

Nos模块初始化接口,对上传资源时使用的各场景资源生命周期进行初始化,开发者最多可自定义10个场景,并指定场景资源的生命周期,并可以对缺省场景(kNIMNosDefaultTagResource、kNIMNosDefaultTagIM)进行覆盖(重新指定生命周期)

Parameters

Name Type Description
param InitNosConfigParam 初始化参数
cb null | InitNosResultCallback 结果回调函数

Returns

Promise<[InitNosResult]>

void 无返回值

Defined in

ts/nim/nos.ts:47


fetchMedia

fetchMedia(msg, jsonExtension, res_cb, prg_cb, speed_cb, transfer_cb): Promise<null | [NIMResCode, string, string, string]>

获取资源

Note

200:成功
10206:下载暂停
408:请求过程超时
其他:参见HTTP协议或CURL错误码

Parameters

Name Type Description
msg IMMessage 消息内容
jsonExtension string json扩展参数
res_cb null | DownloadMediaCallback 下载的回调函数
prg_cb null | ProgressCallback 下载进度的回调函数
speed_cb null | SpeedCallback 下载速度的回调函数
transfer_cb null | TransferInfoCallback 最终下载信息的回调函数

Returns

Promise<null | [NIMResCode, string, string, string]>

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

Defined in

ts/nim/nos.ts:74


stopFetchMedia

stopFetchMedia(msg): boolean

停止获取资源(目前仅对文件消息类型有效)

Note

错误码 10206:成功

Parameters

Name Type Description
msg IMMessage 消息内容

Returns

boolean

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

Defined in

ts/nim/nos.ts:108


uploadResource

uploadResource(local_file, tag, param, res_cb, prg_cb, speed_cb, transfer_cb): Promise<null | [NIMResCode, UploadMediaResult]>

上传资源

Note

200:成功
10200:上传暂停
408:请求过程超时
其他:参见HTTP协议或CURL错误码

Parameters

Name Type Description
local_file string 本地文件的完整路径,路径名必须是utf-8
tag string 场景标签,主要用于确定文件的保存时间
param NOSParams NOS扩展上传\下载接口参数 nim_nos_download_ex"
res_cb null | UploadMediaExCallback 扩展上传的回调函数
prg_cb null | ProgressExCallback 扩展上传进度的回调函数
speed_cb null | SpeedCallback 上传速度的回调函数
transfer_cb null | TransferInfoCallback 最终上传信息的回调函数

Returns

Promise<null | [NIMResCode, UploadMediaResult]>

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

Defined in

ts/nim/nos.ts:130


stopUploadResource

stopUploadResource(task_id, jsonExtension): boolean

停止上传资源(只能用于调用了UploadResource接口的上传任务)

Note

10200:成功

Parameters

Name Type Description
task_id string 停止上传任务的ID
jsonExtension string json扩展参数

Returns

boolean

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

Defined in

ts/nim/nos.ts:170


downloadResource

downloadResource(nosUrl, param, res_cb, prg_cb, speed_cb, transfer_cb): Promise<null | [NIMResCode, DownloadMediaResult]>

下载资源

Note

200:成功
10200:上传暂停
408:请求过程超时
其他:参见HTTP协议或CURL错误码

Parameters

Name Type Description
nosUrl string 下载资源的URL
param NOSParams NOS扩展上传\下载接口参数
res_cb null | DownloadMediaExCallback 扩展下载的回调函数
prg_cb null | ProgressExCallback 扩展下载进度的回调函数
speed_cb null | SpeedCallback 下载速度的回调函数
transfer_cb null | TransferInfoCallback 最终下载信息的回调函数

Returns

Promise<null | [NIMResCode, DownloadMediaResult]>

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

Defined in

ts/nim/nos.ts:190


stopDownloadResource

stopDownloadResource(task_id, jsonExtension): boolean

停止下载资源(只能用于调用了DownloadResourceEx接口的下载任务)

Note

10206:成功

Parameters

Name Type Description
task_id string 停止下载任务的ID
jsonExtension string json扩展参数

Returns

boolean

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

Defined in

ts/nim/nos.ts:228


safeURLToOriginURL

safeURLToOriginURL(safe_url, cb, jsonExtension): Promise<[NIMResCode, string]>

根据安全链接(短链)换取源链接

Note

200:成功
414 不存在该短链或 safe_url 不是一个有效的短链

Parameters

Name Type Description
safe_url string 安全链接(短链)
cb null | SafeURLToOriginURLCallback 结果回调
jsonExtension string json扩展参数

Returns

Promise<[NIMResCode, string]>

void

Defined in

ts/nim/nos.ts:243


setSupportQuickTrans

setSupportQuickTrans(quick): void

打开或关闭文件快传开关

Parameters

Name Type Description
quick boolean 是否打开 true:打开 false:关闭

Returns

void

void

Defined in

ts/nim/nos.ts:262

Properties

nos

nos: NIMNOSAPI

Defined in

ts/nim/nos.ts:31

Constructors

constructor

new NIMNOS()

Overrides

EventEmitter<NIMNOSEvents&gt;.constructor

Defined in

ts/nim/nos.ts:32

Clone this wiki locally