feat: add base methods
This commit is contained in:
80
README.md
80
README.md
@@ -1,12 +1,9 @@
|
|||||||
# JavaScript/TypeScript Client SDK for OpenIM 👨💻💬
|
# Node/Electron Client SDK for OpenIM 👨💻💬
|
||||||
|
|
||||||
Use this SDK to add instant messaging capabilities to your application. By connecting to a self-hosted [OpenIM](https://www.openim.online/) server, you can quickly integrate instant messaging capabilities into your app with just a few lines of code.
|
Use this SDK to add instant messaging capabilities to your application. By connecting to a self-hosted [OpenIM](https://www.openim.online/) server, you can quickly integrate instant messaging capabilities into your app with just a few lines of code.
|
||||||
|
|
||||||
The underlying SDK core is implemented in [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core). Using the [WebAssembly](https://webassembly.org/) support provided by Go language, it can be compiled into wasm for web integration. The web interacts with the [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core) through JSON, and the SDK exposes a re-encapsulated API for easy usage. In terms of data storage, JavaScript handles the logic of the SQL layer by virtualizing SQLite and storing it in IndexedDB using [sql.js](https://sql.js.org/).
|
The underlying SDK core is implemented in [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core). Using the [WebAssembly](https://webassembly.org/) support provided by Go language, it can be compiled into wasm for web integration. The web interacts with the [OpenIM SDK Core](https://github.com/openimsdk/openim-sdk-core) through JSON, and the SDK exposes a re-encapsulated API for easy usage. In terms of data storage, JavaScript handles the logic of the SQL layer by virtualizing SQLite and storing it in IndexedDB using [sql.js](https://sql.js.org/).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Documentation 📚
|
## Documentation 📚
|
||||||
|
|
||||||
Visit [https://doc.rentsoft.cn/](https://doc.rentsoft.cn/) for detailed documentation and guides.
|
Visit [https://doc.rentsoft.cn/](https://doc.rentsoft.cn/) for detailed documentation and guides.
|
||||||
@@ -18,74 +15,7 @@ For the SDK reference, see [https://doc.rentsoft.cn/sdks/quickstart/browser](htt
|
|||||||
### Adding Dependencies
|
### Adding Dependencies
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
npm install open-im-sdk-wasm --save
|
npm install open-im-sdk-node --save
|
||||||
```
|
|
||||||
|
|
||||||
### Obtaining Required Static Resources for WASM
|
|
||||||
|
|
||||||
Follow these steps to obtain the static resources required for WebAssembly (WASM):
|
|
||||||
|
|
||||||
1. Locate the `open-im-sdk-wasm` subdirectory in the `node_modules` directory of your project. Copy all the files in the `assets` folder to your project's public resource directory.
|
|
||||||
|
|
||||||
The files to be copied are:
|
|
||||||
|
|
||||||
- `openIM.wasm`
|
|
||||||
- `sql-wasm.wasm`
|
|
||||||
- `wasm_exec.js`
|
|
||||||
|
|
||||||
2. After copying the files, import the `wasm_exec.js` file in your `index.html` file using a `<script>` tag.
|
|
||||||
|
|
||||||
### Possible Issues ❗
|
|
||||||
|
|
||||||
#### For Webpack 5+
|
|
||||||
|
|
||||||
Add the following configuration to your Webpack configuration:
|
|
||||||
|
|
||||||
```js
|
|
||||||
resolve: {
|
|
||||||
fallback: {
|
|
||||||
fs: false,
|
|
||||||
path: false,
|
|
||||||
crypto: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
```
|
|
||||||
|
|
||||||
#### For Webpack 4 or Vite
|
|
||||||
|
|
||||||
**Note:**
|
|
||||||
If you are using `Webpack 4`, you will also need to install the worker loader.
|
|
||||||
|
|
||||||
```shell
|
|
||||||
npm install worker-loader worker-plugin -D
|
|
||||||
```
|
|
||||||
|
|
||||||
Add the following configuration to your Webpack configuration:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const WorkerPlugin = require("worker-plugin");
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
plugins: [new WorkerPlugin()],
|
|
||||||
|
|
||||||
// ...
|
|
||||||
```
|
|
||||||
|
|
||||||
Follow these steps:
|
|
||||||
|
|
||||||
1. Copy the `lib` directory from the npm package to your project (e.g., `src/utils/lib`).
|
|
||||||
|
|
||||||
2. Modify the import method of the web worker in the `lib/api/index.js` file.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// For Webpack 4:
|
|
||||||
+ import IMWorker from 'worker-loader!./worker.js';
|
|
||||||
// For Vite:
|
|
||||||
+ import IMWorker from './worker?worker';
|
|
||||||
|
|
||||||
- worker = new Worker(new URL('./worker.js', import.meta.url));
|
|
||||||
+ worker = new IMWorker();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage 🚀
|
## Usage 🚀
|
||||||
@@ -95,11 +25,9 @@ The following examples demonstrate how to use the SDK. TypeScript is used, provi
|
|||||||
### Importing the SDK
|
### Importing the SDK
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { getSDK } from 'open-im-sdk-wasm';
|
import OpenIMSDK from 'open-im-sdk-node';
|
||||||
// or your own path after copying
|
|
||||||
// import { getSDK } from '@/utils/lib';
|
|
||||||
|
|
||||||
const OpenIM = getSDK();
|
const OpenIM = new OpenIMSDK();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Logging In and Listening for Connection Status
|
### Logging In and Listening for Connection Status
|
||||||
|
|||||||
BIN
assets/libopenimsdk.dll
Executable file
BIN
assets/libopenimsdk.dll
Executable file
Binary file not shown.
BIN
assets/libopenimsdk.dylib
Executable file
BIN
assets/libopenimsdk.dylib
Executable file
Binary file not shown.
70
package-lock.json
generated
70
package-lock.json
generated
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "openim-sdk-node",
|
"name": "open-im-sdk-node",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "openim-sdk-node",
|
"name": "open-im-sdk-node",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ffi-napi": "^4.0.3",
|
"@openim/ffi-napi": "^4.0.14",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -1813,6 +1813,38 @@
|
|||||||
"@octokit/openapi-types": "^18.0.0"
|
"@octokit/openapi-types": "^18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@openim/ffi-napi": {
|
||||||
|
"version": "4.0.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/@openim/ffi-napi/-/ffi-napi-4.0.14.tgz",
|
||||||
|
"integrity": "sha512-LuKBOFDuV+OKnZr33zaZGKvDgNiozGVg39S++HzywyULBn8vcigW6MGZEYhkx9P5GquAu+Kh+Bkvb2FFY6XRgA==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@openim/ref-napi": "^4.0.11",
|
||||||
|
"debug": "^4.1.1",
|
||||||
|
"get-uv-event-loop-napi-h": "^1.0.5",
|
||||||
|
"node-addon-api": "^3.2.1",
|
||||||
|
"node-gyp-build": "^4.5.0",
|
||||||
|
"ref-struct-di": "^1.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.22.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@openim/ref-napi": {
|
||||||
|
"version": "4.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@openim/ref-napi/-/ref-napi-4.0.11.tgz",
|
||||||
|
"integrity": "sha512-Rz/7M5et4AXBwoTB1Wsm6fNZPlgSs3UB8fxBv3KNZ30W2DYio4NRS3z0rcZgigMuyp/LDGZQjJvhyXCl6QSROg==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"get-symbol-from-current-process-h": "^1.0.2",
|
||||||
|
"node-addon-api": "^3.2.1",
|
||||||
|
"node-gyp-build": "^4.5.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.22.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@pnpm/config.env-replace": {
|
"node_modules/@pnpm/config.env-replace": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pnpm/config.env-replace/-/config.env-replace-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pnpm/config.env-replace/-/config.env-replace-1.1.0.tgz",
|
||||||
@@ -4227,23 +4259,6 @@
|
|||||||
"bser": "2.1.1"
|
"bser": "2.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ffi-napi": {
|
|
||||||
"version": "4.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/ffi-napi/-/ffi-napi-4.0.3.tgz",
|
|
||||||
"integrity": "sha512-PMdLCIvDY9mS32RxZ0XGb95sonPRal8aqRhLbeEtWKZTe2A87qRFG9HjOhvG8EX2UmQw5XNRMIOT+1MYlWmdeg==",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^4.1.1",
|
|
||||||
"get-uv-event-loop-napi-h": "^1.0.5",
|
|
||||||
"node-addon-api": "^3.0.0",
|
|
||||||
"node-gyp-build": "^4.2.1",
|
|
||||||
"ref-napi": "^2.0.1 || ^3.0.2",
|
|
||||||
"ref-struct-di": "^1.1.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/figures": {
|
"node_modules/figures": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
|
||||||
@@ -10402,21 +10417,6 @@
|
|||||||
"esprima": "~4.0.0"
|
"esprima": "~4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ref-napi": {
|
|
||||||
"version": "3.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.3.tgz",
|
|
||||||
"integrity": "sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA==",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^4.1.1",
|
|
||||||
"get-symbol-from-current-process-h": "^1.0.2",
|
|
||||||
"node-addon-api": "^3.0.0",
|
|
||||||
"node-gyp-build": "^4.2.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ref-struct-di": {
|
"node_modules/ref-struct-di": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz",
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
"*.ts": "eslint --cache --cache-location .eslintcache --fix"
|
"*.ts": "eslint --cache --cache-location .eslintcache --fix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"uuid": "^9.0.0",
|
"@openim/ffi-napi": "^4.0.14",
|
||||||
"ffi-napi": "^4.0.3"
|
"uuid": "^9.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import typescript from 'rollup-plugin-typescript2';
|
|
||||||
import alias from '@rollup/plugin-alias';
|
import alias from '@rollup/plugin-alias';
|
||||||
|
import typescript from 'rollup-plugin-typescript2';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import ffi from 'ffi-napi';
|
import ffi from '@openim/ffi-napi';
|
||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
import type { LibOpenIMSDK } from 'libOpenIMSDK';
|
import type { LibOpenIMSDK } from 'libOpenIMSDK';
|
||||||
import { UserModuleApi, setupUserModule } from './modules/user';
|
import { UserModuleApi, setupUserModule } from './modules/user';
|
||||||
import { InitConfig, LoginParams } from '@/types/params';
|
import { InitConfig, LoginParams } from '@/types/params';
|
||||||
import { BaseResponse, SelfUserInfo } from '@/types/entity';
|
import { BaseResponse, SelfUserInfo, EmitProxy } from '@/types/entity';
|
||||||
import { ErrorCode } from '@/constant/api';
|
import { ErrorCode } from '@/constant/api';
|
||||||
import { LoginStatus } from '@/types/enum';
|
import { LoginStatus } from '@/types/enum';
|
||||||
import { NativeEvent, eventMapping } from '@/constant/callback';
|
import { NativeEvent, eventMapping } from '@/constant/callback';
|
||||||
@@ -16,15 +16,9 @@ import {
|
|||||||
} from './modules/conversation';
|
} from './modules/conversation';
|
||||||
import { type MessageModuleApi, setupMessageModule } from './modules/message';
|
import { type MessageModuleApi, setupMessageModule } from './modules/message';
|
||||||
|
|
||||||
const CB_I_S = ffi.Function('void', ['int', 'string']);
|
function isObject(value: unknown) {
|
||||||
const CB_S_I_S_S = ffi.Function('void', ['string', 'int', 'string', 'string']);
|
return Object.prototype.toString.call(value) === '[object Object]';
|
||||||
const CB_S_I_S_S_I = ffi.Function('void', [
|
}
|
||||||
'string',
|
|
||||||
'int',
|
|
||||||
'string',
|
|
||||||
'string',
|
|
||||||
'int',
|
|
||||||
]);
|
|
||||||
|
|
||||||
class OpenIMSDK
|
class OpenIMSDK
|
||||||
extends Emitter
|
extends Emitter
|
||||||
@@ -38,21 +32,22 @@ class OpenIMSDK
|
|||||||
libOpenIMSDK: LibOpenIMSDK;
|
libOpenIMSDK: LibOpenIMSDK;
|
||||||
listenerCallback: Buffer;
|
listenerCallback: Buffer;
|
||||||
|
|
||||||
constructor(libPath: string) {
|
constructor(libPath: string, emitProxy?: EmitProxy) {
|
||||||
super();
|
super();
|
||||||
this.libOpenIMSDK = ffi.Library(libPath, {
|
this.libOpenIMSDK = ffi.Library(libPath, {
|
||||||
set_group_listener: ['void', [CB_I_S]],
|
set_group_listener: ['void', ['pointer']],
|
||||||
set_conversation_listener: ['void', [CB_I_S]],
|
set_conversation_listener: ['void', ['pointer']],
|
||||||
set_advanced_msg_listener: ['void', [CB_I_S]],
|
set_advanced_msg_listener: ['void', ['pointer']],
|
||||||
set_batch_msg_listener: ['void', [CB_I_S]],
|
set_batch_msg_listener: ['void', ['pointer']],
|
||||||
set_user_listener: ['void', [CB_I_S]],
|
set_user_listener: ['void', ['pointer']],
|
||||||
set_friend_listener: ['void', [CB_I_S]],
|
set_friend_listener: ['void', ['pointer']],
|
||||||
set_custom_business_listener: ['void', [CB_I_S]],
|
set_custom_business_listener: ['void', ['pointer']],
|
||||||
init_sdk: ['uint8', [CB_I_S, 'string', 'string']],
|
init_sdk: ['uint8', ['pointer', 'string', 'string']],
|
||||||
un_init_sdk: ['void', ['string']],
|
un_init_sdk: ['void', ['string']],
|
||||||
login: ['void', [CB_S_I_S_S, 'string', 'string', 'string']],
|
login: ['void', ['pointer', 'string', 'string', 'string']],
|
||||||
logout: ['void', [CB_S_I_S_S, 'string']],
|
logout: ['void', ['pointer', 'string']],
|
||||||
network_status_changed: ['void', [CB_S_I_S_S, 'string']],
|
set_app_background_status: ['void', ['pointer', 'string', 'int']],
|
||||||
|
network_status_changed: ['void', ['pointer', 'string']],
|
||||||
get_login_status: ['int', ['string']],
|
get_login_status: ['int', ['string']],
|
||||||
get_login_user: ['string', []],
|
get_login_user: ['string', []],
|
||||||
create_text_message: ['string', ['string', 'string']],
|
create_text_message: ['string', ['string', 'string']],
|
||||||
@@ -91,7 +86,7 @@ class OpenIMSDK
|
|||||||
create_image_message: ['string', ['string', 'string']],
|
create_image_message: ['string', ['string', 'string']],
|
||||||
create_image_message_by_url: [
|
create_image_message_by_url: [
|
||||||
'string',
|
'string',
|
||||||
['string', 'string', 'string', 'string'],
|
['string', 'string', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
create_sound_message_by_url: ['string', ['string', 'string']],
|
create_sound_message_by_url: ['string', ['string', 'string']],
|
||||||
create_sound_message: ['string', ['string', 'string', 'long long']],
|
create_sound_message: ['string', ['string', 'string', 'long long']],
|
||||||
@@ -108,93 +103,178 @@ class OpenIMSDK
|
|||||||
],
|
],
|
||||||
create_face_message: ['string', ['string', 'int', 'string']],
|
create_face_message: ['string', ['string', 'int', 'string']],
|
||||||
create_forward_message: ['string', ['string', 'string']],
|
create_forward_message: ['string', ['string', 'string']],
|
||||||
get_all_conversation_list: ['void', [CB_S_I_S_S, 'string']],
|
get_all_conversation_list: ['void', ['pointer', 'string']],
|
||||||
get_advanced_history_message_list: [
|
get_conversation_list_split: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string'],
|
['pointer', 'string', 'int', 'int'],
|
||||||
|
],
|
||||||
|
get_one_conversation: ['void', ['pointer', 'string', 'int', 'string']],
|
||||||
|
get_multiple_conversation: ['void', ['pointer', 'string', 'string']],
|
||||||
|
set_conversation_msg_destruct_time: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'long long'],
|
||||||
|
],
|
||||||
|
set_conversation_is_msg_destruct: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'int'],
|
||||||
|
],
|
||||||
|
hide_conversation: ['void', ['pointer', 'string', 'string']],
|
||||||
|
get_conversation_recv_message_opt: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string'],
|
||||||
|
],
|
||||||
|
set_conversation_draft: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'string'],
|
||||||
|
],
|
||||||
|
reset_conversation_group_at_type: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string'],
|
||||||
|
],
|
||||||
|
pin_conversation: ['void', ['pointer', 'string', 'string', 'int']],
|
||||||
|
set_conversation_private_chat: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'int'],
|
||||||
|
],
|
||||||
|
set_conversation_burn_duration: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'int'],
|
||||||
|
],
|
||||||
|
set_conversation_recv_message_opt: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'int'],
|
||||||
|
],
|
||||||
|
get_total_unread_msg_count: ['void', ['pointer', 'string']],
|
||||||
|
get_at_all_tag: ['string', ['string']],
|
||||||
|
get_conversation_id_by_session_type: [
|
||||||
|
'string',
|
||||||
|
['string', 'string', 'int'],
|
||||||
],
|
],
|
||||||
send_message: [
|
send_message: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S_I, 'string', 'string', 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
|
send_message_not_oss: [
|
||||||
// User related functions
|
'void',
|
||||||
get_users_info: ['void', [CB_S_I_S_S, 'string', 'string']],
|
['pointer', 'string', 'string', 'string', 'string', 'string'],
|
||||||
get_users_info_from_srv: ['void', [CB_S_I_S_S, 'string', 'string']],
|
],
|
||||||
set_self_info: ['void', [CB_S_I_S_S, 'string', 'string']],
|
find_message_list: ['void', ['pointer', 'string', 'string']],
|
||||||
get_self_user_info: ['void', [CB_S_I_S_S, 'string']],
|
get_advanced_history_message_list: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string'],
|
||||||
|
],
|
||||||
|
get_advanced_history_message_list_reverse: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string'],
|
||||||
|
],
|
||||||
|
revoke_message: ['void', ['pointer', 'string', 'string', 'string']],
|
||||||
|
typing_status_update: ['void', ['pointer', 'string', 'string', 'string']],
|
||||||
|
mark_conversation_message_as_read: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string'],
|
||||||
|
],
|
||||||
|
delete_message_from_local_storage: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'string'],
|
||||||
|
],
|
||||||
|
delete_message: ['void', ['pointer', 'string', 'string', 'string']],
|
||||||
|
hide_all_conversations: ['void', ['pointer', 'string']],
|
||||||
|
delete_all_msg_from_local_and_svr: ['void', ['pointer', 'string']],
|
||||||
|
delete_all_msg_from_local: ['void', ['pointer', 'string']],
|
||||||
|
clear_conversation_and_delete_all_msg: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string'],
|
||||||
|
],
|
||||||
|
delete_conversation_and_delete_all_msg: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string'],
|
||||||
|
],
|
||||||
|
insert_single_message_to_local_storage: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
|
],
|
||||||
|
insert_group_message_to_local_storage: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
|
],
|
||||||
|
search_local_messages: ['void', ['pointer', 'string', 'string']],
|
||||||
|
set_message_local_ex: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
|
],
|
||||||
|
get_users_info: ['void', ['pointer', 'string', 'string']],
|
||||||
|
get_users_info_with_cache: [
|
||||||
|
'void',
|
||||||
|
['pointer', 'string', 'string', 'string'],
|
||||||
|
],
|
||||||
|
get_users_info_from_srv: ['void', ['pointer', 'string', 'string']],
|
||||||
|
set_self_info: ['void', ['pointer', 'string', 'string']],
|
||||||
|
set_global_recv_message_opt: ['void', ['pointer', 'string', 'int']],
|
||||||
|
get_self_user_info: ['void', ['pointer', 'string']],
|
||||||
update_msg_sender_info: [
|
update_msg_sender_info: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
subscribe_users_status: ['void', [CB_S_I_S_S, 'string', 'string']],
|
subscribe_users_status: ['void', ['pointer', 'string', 'string']],
|
||||||
unsubscribe_users_status: ['void', [CB_S_I_S_S, 'string', 'string']],
|
unsubscribe_users_status: ['void', ['pointer', 'string', 'string']],
|
||||||
get_subscribe_users_status: ['void', [CB_S_I_S_S, 'string']],
|
get_subscribe_users_status: ['void', ['pointer', 'string']],
|
||||||
get_user_status: ['void', [CB_S_I_S_S, 'string', 'string']],
|
get_user_status: ['void', ['pointer', 'string', 'string']],
|
||||||
|
// Friend functions
|
||||||
// Friend related functions
|
get_specified_friends_info: ['void', ['pointer', 'string', 'string']],
|
||||||
get_specified_friends_info: ['void', [CB_S_I_S_S, 'string', 'string']],
|
get_friend_list: ['void', ['pointer', 'string']],
|
||||||
get_friend_list: ['void', [CB_S_I_S_S, 'string']],
|
get_friend_list_page: ['void', ['pointer', 'string', 'int', 'int']],
|
||||||
get_friend_list_page: ['void', [CB_S_I_S_S, 'string', 'int', 'int']],
|
search_friends: ['void', ['pointer', 'string', 'string']],
|
||||||
search_friends: ['void', [CB_S_I_S_S, 'string', 'string']],
|
check_friend: ['void', ['pointer', 'string', 'string']],
|
||||||
check_friend: ['void', [CB_S_I_S_S, 'string', 'string']],
|
add_friend: ['void', ['pointer', 'string', 'string']],
|
||||||
add_friend: ['void', [CB_S_I_S_S, 'string', 'string']],
|
set_friend_remark: ['void', ['pointer', 'string', 'string']],
|
||||||
set_friend_remark: ['void', [CB_S_I_S_S, 'string', 'string']],
|
delete_friend: ['void', ['pointer', 'string', 'string']],
|
||||||
delete_friend: ['void', [CB_S_I_S_S, 'string', 'string']],
|
get_friend_application_list_as_recipient: ['void', ['pointer', 'string']],
|
||||||
get_friend_application_list_as_recipient: [
|
get_friend_application_list_as_applicant: ['void', ['pointer', 'string']],
|
||||||
'void',
|
accept_friend_application: ['void', ['pointer', 'string', 'string']],
|
||||||
[CB_S_I_S_S, 'string'],
|
refuse_friend_application: ['void', ['pointer', 'string', 'string']],
|
||||||
],
|
add_black: ['void', ['pointer', 'string', 'string']],
|
||||||
get_friend_application_list_as_applicant: [
|
get_black_list: ['void', ['pointer', 'string']],
|
||||||
'void',
|
remove_black: ['void', ['pointer', 'string', 'string']],
|
||||||
[CB_S_I_S_S, 'string'],
|
// Group functions
|
||||||
],
|
create_group: ['void', ['pointer', 'string', 'string']],
|
||||||
accept_friend_application: ['void', [CB_S_I_S_S, 'string', 'string']],
|
join_group: ['void', ['pointer', 'string', 'string', 'string', 'int']],
|
||||||
refuse_friend_application: ['void', [CB_S_I_S_S, 'string', 'string']],
|
quit_group: ['void', ['pointer', 'string', 'string']],
|
||||||
add_black: ['void', [CB_S_I_S_S, 'string', 'string']],
|
dismiss_group: ['void', ['pointer', 'string', 'string']],
|
||||||
get_black_list: ['void', [CB_S_I_S_S, 'string']],
|
change_group_mute: ['void', ['pointer', 'string', 'string', 'int']],
|
||||||
remove_black: ['void', [CB_S_I_S_S, 'string', 'string']],
|
|
||||||
|
|
||||||
// Group related functions
|
|
||||||
create_group: ['void', [CB_S_I_S_S, 'string', 'string']],
|
|
||||||
join_group: ['void', [CB_S_I_S_S, 'string', 'string', 'string', 'int']],
|
|
||||||
quit_group: ['void', [CB_S_I_S_S, 'string', 'string']],
|
|
||||||
dismiss_group: ['void', [CB_S_I_S_S, 'string', 'string']],
|
|
||||||
change_group_mute: ['void', [CB_S_I_S_S, 'string', 'string', 'int']],
|
|
||||||
change_group_member_mute: [
|
change_group_member_mute: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string', 'int'],
|
['pointer', 'string', 'string', 'string', 'int'],
|
||||||
],
|
],
|
||||||
set_group_member_role_level: [
|
set_group_member_role_level: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string', 'int'],
|
['pointer', 'string', 'string', 'string', 'int'],
|
||||||
],
|
],
|
||||||
set_group_member_info: ['void', [CB_S_I_S_S, 'string', 'string']],
|
set_group_member_info: ['void', ['pointer', 'string', 'string']],
|
||||||
get_joined_group_list: ['void', [CB_S_I_S_S, 'string']],
|
get_joined_group_list: ['void', ['pointer', 'string']],
|
||||||
get_specified_groups_info: ['void', [CB_S_I_S_S, 'string', 'string']],
|
get_specified_groups_info: ['void', ['pointer', 'string', 'string']],
|
||||||
search_groups: ['void', [CB_S_I_S_S, 'string', 'string']],
|
search_groups: ['void', ['pointer', 'string', 'string']],
|
||||||
set_group_info: ['void', [CB_S_I_S_S, 'string', 'string']],
|
set_group_info: ['void', ['pointer', 'string', 'string']],
|
||||||
set_group_verification: ['void', [CB_S_I_S_S, 'string', 'string', 'int']],
|
set_group_verification: ['void', ['pointer', 'string', 'string', 'int']],
|
||||||
set_group_look_member_info: [
|
set_group_look_member_info: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'int'],
|
['pointer', 'string', 'string', 'int'],
|
||||||
],
|
],
|
||||||
set_group_apply_member_friend: [
|
set_group_apply_member_friend: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'int'],
|
['pointer', 'string', 'string', 'int'],
|
||||||
],
|
],
|
||||||
get_group_member_list: [
|
get_group_member_list: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'int', 'int', 'int'],
|
['pointer', 'string', 'string', 'int', 'int', 'int'],
|
||||||
],
|
],
|
||||||
get_group_member_owner_and_admin: [
|
get_group_member_owner_and_admin: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string'],
|
['pointer', 'string', 'string'],
|
||||||
],
|
],
|
||||||
get_group_member_list_by_join_time_filter: [
|
get_group_member_list_by_join_time_filter: [
|
||||||
'void',
|
'void',
|
||||||
[
|
[
|
||||||
CB_S_I_S_S,
|
'pointer',
|
||||||
'string',
|
'string',
|
||||||
'string',
|
'string',
|
||||||
'int',
|
'int',
|
||||||
@@ -206,44 +286,43 @@ class OpenIMSDK
|
|||||||
],
|
],
|
||||||
get_specified_group_members_info: [
|
get_specified_group_members_info: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
kick_group_member: [
|
kick_group_member: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
],
|
|
||||||
transfer_group_owner: [
|
|
||||||
'void',
|
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string'],
|
|
||||||
],
|
],
|
||||||
|
transfer_group_owner: ['void', ['pointer', 'string', 'string', 'string']],
|
||||||
invite_user_to_group: [
|
invite_user_to_group: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
get_group_application_list_as_recipient: ['void', [CB_S_I_S_S, 'string']],
|
get_group_application_list_as_recipient: ['void', ['pointer', 'string']],
|
||||||
get_group_application_list_as_applicant: ['void', [CB_S_I_S_S, 'string']],
|
get_group_application_list_as_applicant: ['void', ['pointer', 'string']],
|
||||||
accept_group_application: [
|
accept_group_application: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
refuse_group_application: [
|
refuse_group_application: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
set_group_member_nickname: [
|
set_group_member_nickname: [
|
||||||
'void',
|
'void',
|
||||||
[CB_S_I_S_S, 'string', 'string', 'string', 'string'],
|
['pointer', 'string', 'string', 'string', 'string'],
|
||||||
],
|
],
|
||||||
search_group_members: ['void', [CB_S_I_S_S, 'string', 'string']],
|
search_group_members: ['void', ['pointer', 'string', 'string']],
|
||||||
is_join_group: ['void', [CB_S_I_S_S, 'string', 'string']],
|
is_join_group: ['void', ['pointer', 'string', 'string']],
|
||||||
}) as LibOpenIMSDK;
|
}) as LibOpenIMSDK;
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const emitFn = emitProxy ?? this.emit;
|
||||||
this.listenerCallback = ffi.Callback(
|
this.listenerCallback = ffi.Callback(
|
||||||
'void',
|
'void',
|
||||||
['int', 'string'],
|
['int', 'string'],
|
||||||
(event: NativeEvent, data) => {
|
(event: NativeEvent, data) => {
|
||||||
const cbEvent = eventMapping[event];
|
const cbEvent = eventMapping[event];
|
||||||
this.emit(cbEvent, data);
|
emitFn(cbEvent, this.generateEventResponse(data));
|
||||||
console.log(`listener callback - Event: ${cbEvent}, Data: ${data}`);
|
console.log(`listener callback - Event: ${cbEvent}, Data: ${data}`);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -255,6 +334,31 @@ class OpenIMSDK
|
|||||||
Object.assign(this, setupMessageModule(this));
|
Object.assign(this, setupMessageModule(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateEventResponse = (data: unknown): BaseResponse => {
|
||||||
|
let errCode = 0;
|
||||||
|
let errMsg = '';
|
||||||
|
try {
|
||||||
|
data = JSON.parse(data as string);
|
||||||
|
} catch (error) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
if (isObject(data) && data.errCode !== undefined) {
|
||||||
|
// @ts-ignore
|
||||||
|
errCode = data.errCode;
|
||||||
|
// @ts-ignore
|
||||||
|
errMsg = data.errMsg;
|
||||||
|
// @ts-ignore
|
||||||
|
data = data.data;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
errCode,
|
||||||
|
errMsg,
|
||||||
|
data,
|
||||||
|
operationID: '',
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
baseCallbackWrap = <T>(
|
baseCallbackWrap = <T>(
|
||||||
resolve: (response: BaseResponse<T>) => void,
|
resolve: (response: BaseResponse<T>) => void,
|
||||||
reject: (response: BaseResponse<T>) => void
|
reject: (response: BaseResponse<T>) => void
|
||||||
@@ -358,8 +462,31 @@ class OpenIMSDK
|
|||||||
this.libOpenIMSDK.un_init_sdk(`unInitSDK-${opid}`)
|
this.libOpenIMSDK.un_init_sdk(`unInitSDK-${opid}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setAppBackgroundStatus = (isInBackground: boolean, opid = uuidV4()) =>
|
||||||
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
|
this.libOpenIMSDK.set_app_background_status(
|
||||||
|
this.baseCallbackWrap<void>(resolve, reject),
|
||||||
|
opid,
|
||||||
|
isInBackground ? 1 : 0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
networkStatusChanged = (opid = uuidV4()) =>
|
||||||
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
|
this.libOpenIMSDK.network_status_changed(
|
||||||
|
this.baseCallbackWrap<void>(resolve, reject),
|
||||||
|
opid
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// implements user api
|
// implements user api
|
||||||
getSelfUserInfo!: UserModuleApi['getSelfUserInfo'];
|
getSelfUserInfo!: UserModuleApi['getSelfUserInfo'];
|
||||||
|
setSelfInfo!: UserModuleApi['setSelfInfo'];
|
||||||
|
getUsersInfoWithCache!: UserModuleApi['getUsersInfoWithCache'];
|
||||||
|
subscribeUsersStatus!: UserModuleApi['subscribeUsersStatus'];
|
||||||
|
unsubscribeUsersStatus!: UserModuleApi['unsubscribeUsersStatus'];
|
||||||
|
getSubscribeUsersStatus!: UserModuleApi['getSubscribeUsersStatus'];
|
||||||
|
setGlobalRecvMessageOpt!: UserModuleApi['setGlobalRecvMessageOpt'];
|
||||||
|
|
||||||
// implements friend api
|
// implements friend api
|
||||||
acceptFriendApplication!: FriendModuleApi['acceptFriendApplication'];
|
acceptFriendApplication!: FriendModuleApi['acceptFriendApplication'];
|
||||||
@@ -404,6 +531,22 @@ class OpenIMSDK
|
|||||||
|
|
||||||
// implements conversation api
|
// implements conversation api
|
||||||
getAllConversationList!: ConversationModuleApi['getAllConversationList'];
|
getAllConversationList!: ConversationModuleApi['getAllConversationList'];
|
||||||
|
getConversationListSplit!: ConversationModuleApi['getConversationListSplit'];
|
||||||
|
getOneConversation!: ConversationModuleApi['getOneConversation'];
|
||||||
|
getMultipleConversation!: ConversationModuleApi['getMultipleConversation'];
|
||||||
|
getConversationIDBySessionType!: ConversationModuleApi['getConversationIDBySessionType'];
|
||||||
|
getTotalUnreadMsgCount!: ConversationModuleApi['getTotalUnreadMsgCount'];
|
||||||
|
markConversationMessageAsRead!: ConversationModuleApi['markConversationMessageAsRead'];
|
||||||
|
setConversationDraft!: ConversationModuleApi['setConversationDraft'];
|
||||||
|
pinConversation!: ConversationModuleApi['pinConversation'];
|
||||||
|
setConversationRecvMessageOpt!: ConversationModuleApi['setConversationRecvMessageOpt'];
|
||||||
|
setConversationPrivateChat!: ConversationModuleApi['setConversationPrivateChat'];
|
||||||
|
setConversationBurnDuration!: ConversationModuleApi['setConversationBurnDuration'];
|
||||||
|
resetConversationGroupAtType!: ConversationModuleApi['resetConversationGroupAtType'];
|
||||||
|
hideConversation!: ConversationModuleApi['hideConversation'];
|
||||||
|
hideAllConversation!: ConversationModuleApi['hideAllConversation'];
|
||||||
|
clearConversationAndDeleteAllMsg!: ConversationModuleApi['clearConversationAndDeleteAllMsg'];
|
||||||
|
deleteConversationAndDeleteAllMsg!: ConversationModuleApi['deleteConversationAndDeleteAllMsg'];
|
||||||
|
|
||||||
// implements message api
|
// implements message api
|
||||||
createTextMessage!: MessageModuleApi['createTextMessage'];
|
createTextMessage!: MessageModuleApi['createTextMessage'];
|
||||||
@@ -428,7 +571,20 @@ class OpenIMSDK
|
|||||||
createFileMessageFromFullPath!: MessageModuleApi['createFileMessageFromFullPath'];
|
createFileMessageFromFullPath!: MessageModuleApi['createFileMessageFromFullPath'];
|
||||||
createFileMessageByUrl!: MessageModuleApi['createFileMessageByUrl'];
|
createFileMessageByUrl!: MessageModuleApi['createFileMessageByUrl'];
|
||||||
getAdvancedHistoryMessageList!: MessageModuleApi['getAdvancedHistoryMessageList'];
|
getAdvancedHistoryMessageList!: MessageModuleApi['getAdvancedHistoryMessageList'];
|
||||||
|
getAdvancedHistoryMessageListReverse!: MessageModuleApi['getAdvancedHistoryMessageListReverse'];
|
||||||
sendMessage!: MessageModuleApi['sendMessage'];
|
sendMessage!: MessageModuleApi['sendMessage'];
|
||||||
|
sendMessageNotOss!: MessageModuleApi['sendMessageNotOss'];
|
||||||
|
findMessageList!: MessageModuleApi['findMessageList'];
|
||||||
|
revokeMessage!: MessageModuleApi['revokeMessage'];
|
||||||
|
typingStatusUpdate!: MessageModuleApi['typingStatusUpdate'];
|
||||||
|
deleteMessageFromLocalStorage!: MessageModuleApi['deleteMessageFromLocalStorage'];
|
||||||
|
deleteMessage!: MessageModuleApi['deleteMessage'];
|
||||||
|
deleteAllMsgFromLocalAndSvr!: MessageModuleApi['deleteAllMsgFromLocalAndSvr'];
|
||||||
|
deleteAllMsgFromLocal!: MessageModuleApi['deleteAllMsgFromLocal'];
|
||||||
|
searchLocalMessages!: MessageModuleApi['searchLocalMessages'];
|
||||||
|
insertGroupMessageToLocalStorage!: MessageModuleApi['insertGroupMessageToLocalStorage'];
|
||||||
|
insertSingleMessageToLocalStorage!: MessageModuleApi['insertSingleMessageToLocalStorage'];
|
||||||
|
setMessageLocalEx!: MessageModuleApi['setMessageLocalEx'];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OpenIMSDK;
|
export default OpenIMSDK;
|
||||||
|
|||||||
@@ -1,174 +1,183 @@
|
|||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
import { BaseResponse, ConversationItem } from '@/types/entity';
|
import { BaseResponse, ConversationItem } from '@/types/entity';
|
||||||
import OpenIMSDK from '..';
|
import OpenIMSDK from '..';
|
||||||
|
import {
|
||||||
|
SplitConversationParams,
|
||||||
|
GetOneConversationParams,
|
||||||
|
SetConversationDraftParams,
|
||||||
|
PinConversationParams,
|
||||||
|
SetConversationRecvOptParams,
|
||||||
|
SetConversationPrivateParams,
|
||||||
|
SetBurnDurationParams,
|
||||||
|
} from '@/types/params';
|
||||||
|
|
||||||
export function setupConversationModule(openIMSDK: OpenIMSDK) {
|
export function setupConversationModule(openIMSDK: OpenIMSDK) {
|
||||||
return {
|
return {
|
||||||
// getAllConversationList: (opid = uuidV4()) =>
|
getAllConversationList: (opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<ConversationItem[]>>((resolve, reject) => {
|
new Promise<BaseResponse<ConversationItem[]>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.get_all_conversation_list(
|
openIMSDK.libOpenIMSDK.get_all_conversation_list(
|
||||||
// openIMSDK.baseCallbackWrap<ConversationItem[]>(resolve, reject),
|
openIMSDK.baseCallbackWrap<ConversationItem[]>(resolve, reject),
|
||||||
// opid
|
opid
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// getConversationListSplit: (
|
getConversationListSplit: (
|
||||||
// params: SplitConversationParams,
|
params: SplitConversationParams,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<ConversationItem[]>>((resolve, reject) => {
|
new Promise<BaseResponse<ConversationItem[]>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.get_conversation_list_split(
|
openIMSDK.libOpenIMSDK.get_conversation_list_split(
|
||||||
// openIMSDK.baseCallbackWrap<ConversationItem[]>(resolve, reject),
|
openIMSDK.baseCallbackWrap<ConversationItem[]>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.offset,
|
params.offset,
|
||||||
// params.count
|
params.count
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// getOneConversation: (params: GetOneConversationParams, opid = uuidV4()) =>
|
getOneConversation: (params: GetOneConversationParams, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<ConversationItem>>((resolve, reject) => {
|
new Promise<BaseResponse<ConversationItem>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.get_one_conversation(
|
openIMSDK.libOpenIMSDK.get_one_conversation(
|
||||||
// openIMSDK.baseCallbackWrap<ConversationItem>(resolve, reject),
|
openIMSDK.baseCallbackWrap<ConversationItem>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.sessionType,
|
params.sessionType,
|
||||||
// params.sourceID
|
params.sourceID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// getMultipleConversation: (conversationIDList: string, opid = uuidV4()) =>
|
getMultipleConversation: (conversationIDList: string, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<ConversationItem[]>>((resolve, reject) => {
|
new Promise<BaseResponse<ConversationItem[]>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.get_multiple_conversation(
|
openIMSDK.libOpenIMSDK.get_multiple_conversation(
|
||||||
// openIMSDK.baseCallbackWrap<ConversationItem[]>(resolve, reject),
|
openIMSDK.baseCallbackWrap<ConversationItem[]>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// conversationIDList
|
conversationIDList
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// getConversationIDBySessionType: (
|
getConversationIDBySessionType: (
|
||||||
// params: GetOneConversationParams,
|
params: GetOneConversationParams,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<ConversationItem>>((resolve, reject) => {
|
openIMSDK.asyncRetunWrap<string>(
|
||||||
// openIMSDK.libOpenIMSDK.get_conversation_id_by_session_type(
|
opid,
|
||||||
// openIMSDK.baseCallbackWrap<ConversationItem>(resolve, reject),
|
openIMSDK.libOpenIMSDK.get_conversation_id_by_session_type(
|
||||||
// opid,
|
opid,
|
||||||
// params.sourceID,
|
params.sourceID,
|
||||||
// params.sessionType
|
params.sessionType
|
||||||
// );
|
)
|
||||||
// }),
|
),
|
||||||
// getTotalUnreadMsgCount: (opid = uuidV4()) =>
|
getTotalUnreadMsgCount: (opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<number>>((resolve, reject) => {
|
new Promise<BaseResponse<number>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.get_total_unread_msg_count(
|
openIMSDK.libOpenIMSDK.get_total_unread_msg_count(
|
||||||
// openIMSDK.baseCallbackWrap<number>(resolve, reject),
|
openIMSDK.baseCallbackWrap<number>(resolve, reject),
|
||||||
// opid
|
opid
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// markConversationMessageAsRead: (conversationID: string, opid = uuidV4()) =>
|
markConversationMessageAsRead: (conversationID: string, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.mark_conversation_message_as_read(
|
openIMSDK.libOpenIMSDK.mark_conversation_message_as_read(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// conversationID
|
conversationID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// setConversationDraft: (
|
setConversationDraft: (
|
||||||
// params: SetConversationDraftParams,
|
params: SetConversationDraftParams,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.set_conversation_draft(
|
openIMSDK.libOpenIMSDK.set_conversation_draft(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.conversationID,
|
params.conversationID,
|
||||||
// params.draftText
|
params.draftText
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// pinConversation: (params: PinConversationParams, opid = uuidV4()) =>
|
pinConversation: (params: PinConversationParams, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.pin_conversation(
|
openIMSDK.libOpenIMSDK.pin_conversation(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.conversationID,
|
params.conversationID,
|
||||||
// params.isPinned ? 1 : 0
|
params.isPinned ? 1 : 0
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// setConversationRecvMessageOpt: (
|
setConversationRecvMessageOpt: (
|
||||||
// params: SetConversationRecvOptParams,
|
params: SetConversationRecvOptParams,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.set_conversation_recv_message_opt(
|
openIMSDK.libOpenIMSDK.set_conversation_recv_message_opt(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.conversationID,
|
params.conversationID,
|
||||||
// params.opt
|
params.opt
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// setConversationPrivateChat: (
|
setConversationPrivateChat: (
|
||||||
// params: SetConversationPrivateParams,
|
params: SetConversationPrivateParams,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.set_conversation_private_chat(
|
openIMSDK.libOpenIMSDK.set_conversation_private_chat(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.conversationID,
|
params.conversationID,
|
||||||
// params.isPrivate
|
params.isPrivate ? 1 : 0
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// setConversationBurnDuration: (
|
setConversationBurnDuration: (
|
||||||
// params: SetBurnDurationParams,
|
params: SetBurnDurationParams,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.set_conversation_burn_duration(
|
openIMSDK.libOpenIMSDK.set_conversation_burn_duration(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.conversationID,
|
params.conversationID,
|
||||||
// params.burnDuration
|
params.burnDuration
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// resetConversationGroupAtType: (groupID: string, opid = uuidV4()) =>
|
resetConversationGroupAtType: (groupID: string, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.reset_conversation_group_at_type(
|
openIMSDK.libOpenIMSDK.reset_conversation_group_at_type(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// groupID
|
groupID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// hideConversation: (conversationID: string, opid = uuidV4()) =>
|
hideConversation: (conversationID: string, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.hide_conversation(
|
openIMSDK.libOpenIMSDK.hide_conversation(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// conversationID
|
conversationID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// hideAllConversation: (opid = uuidV4()) =>
|
hideAllConversation: (opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.hide_all_conversation(
|
openIMSDK.libOpenIMSDK.hide_all_conversations(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid
|
opid
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// clearConversationAndDeleteAllMsg: (
|
clearConversationAndDeleteAllMsg: (
|
||||||
// conversationID: string,
|
conversationID: string,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.clear_conversation_and_delete_all_msg(
|
openIMSDK.libOpenIMSDK.clear_conversation_and_delete_all_msg(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// conversationID
|
conversationID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
// deleteConversationAndDeleteAllMsg: (
|
deleteConversationAndDeleteAllMsg: (
|
||||||
// conversationID: string,
|
conversationID: string,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.delete_conversation_and_delete_all_msg(
|
openIMSDK.libOpenIMSDK.delete_conversation_and_delete_all_msg(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// conversationID
|
conversationID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,4 +185,62 @@ export interface ConversationModuleApi {
|
|||||||
getAllConversationList: (
|
getAllConversationList: (
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<ConversationItem[]>>;
|
) => Promise<BaseResponse<ConversationItem[]>>;
|
||||||
|
getConversationListSplit: (
|
||||||
|
params: SplitConversationParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<ConversationItem[]>>;
|
||||||
|
getOneConversation: (
|
||||||
|
params: GetOneConversationParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<ConversationItem>>;
|
||||||
|
getMultipleConversation: (
|
||||||
|
conversationIDList: string,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<ConversationItem[]>>;
|
||||||
|
getConversationIDBySessionType: (
|
||||||
|
params: GetOneConversationParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<string>>;
|
||||||
|
getTotalUnreadMsgCount: (opid?: string) => Promise<BaseResponse<number>>;
|
||||||
|
markConversationMessageAsRead: (
|
||||||
|
conversationID: string,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
setConversationDraft: (
|
||||||
|
params: SetConversationDraftParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
pinConversation: (
|
||||||
|
params: PinConversationParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
setConversationRecvMessageOpt: (
|
||||||
|
params: SetConversationRecvOptParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
setConversationPrivateChat: (
|
||||||
|
params: SetConversationPrivateParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
setConversationBurnDuration: (
|
||||||
|
params: SetBurnDurationParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
resetConversationGroupAtType: (
|
||||||
|
groupID: string,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
hideConversation: (
|
||||||
|
conversationID: string,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
hideAllConversation: (opid?: string) => Promise<BaseResponse<void>>;
|
||||||
|
clearConversationAndDeleteAllMsg: (
|
||||||
|
conversationID: string,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
deleteConversationAndDeleteAllMsg: (
|
||||||
|
conversationID: string,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
AccessFriendParams,
|
AccessFriendParams,
|
||||||
SearchFriendParams,
|
SearchFriendParams,
|
||||||
RemarkFriendParams,
|
RemarkFriendParams,
|
||||||
|
AddFriendParams,
|
||||||
} from '@/types/params';
|
} from '@/types/params';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -35,12 +36,12 @@ export function setupFriendModule(openIMSDK: OpenIMSDK) {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
addFriend: (userID: string, opid = uuidV4()) =>
|
addFriend: (params: AddFriendParams, opid = uuidV4()) =>
|
||||||
new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
openIMSDK.libOpenIMSDK.add_friend(
|
openIMSDK.libOpenIMSDK.add_friend(
|
||||||
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
opid,
|
opid,
|
||||||
userID
|
JSON.stringify(params)
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,21 @@ import {
|
|||||||
FaceMessageParams,
|
FaceMessageParams,
|
||||||
FileMsgByPathParams,
|
FileMsgByPathParams,
|
||||||
FileMsgByUrlParams,
|
FileMsgByUrlParams,
|
||||||
|
FindMessageParams,
|
||||||
GetAdvancedHistoryMsgParams,
|
GetAdvancedHistoryMsgParams,
|
||||||
ImageMsgByUrlParams,
|
ImageMsgByUrlParams,
|
||||||
|
InsertGroupMsgParams,
|
||||||
|
InsertSingleMsgParams,
|
||||||
LocationMsgParams,
|
LocationMsgParams,
|
||||||
MergerMsgParams,
|
MergerMsgParams,
|
||||||
|
OpreateMessageParams,
|
||||||
QuoteMsgParams,
|
QuoteMsgParams,
|
||||||
|
SearchLocalParams,
|
||||||
SendMsgParams,
|
SendMsgParams,
|
||||||
|
SetMessageLocalExParams,
|
||||||
SoundMsgByPathParams,
|
SoundMsgByPathParams,
|
||||||
SoundMsgByUrlParams,
|
SoundMsgByUrlParams,
|
||||||
|
TypingUpdateParams,
|
||||||
VideoMsgByPathParams,
|
VideoMsgByPathParams,
|
||||||
VideoMsgByUrlParams,
|
VideoMsgByUrlParams,
|
||||||
} from '@/types/params';
|
} from '@/types/params';
|
||||||
@@ -132,6 +139,7 @@ export function setupMessageModule(openIMSDK: OpenIMSDK) {
|
|||||||
opid,
|
opid,
|
||||||
openIMSDK.libOpenIMSDK.create_image_message_by_url(
|
openIMSDK.libOpenIMSDK.create_image_message_by_url(
|
||||||
opid,
|
opid,
|
||||||
|
params.sourcePath,
|
||||||
JSON.stringify(params.sourcePicture),
|
JSON.stringify(params.sourcePicture),
|
||||||
JSON.stringify(params.bigPicture),
|
JSON.stringify(params.bigPicture),
|
||||||
JSON.stringify(params.snapshotPicture)
|
JSON.stringify(params.snapshotPicture)
|
||||||
@@ -257,89 +265,92 @@ export function setupMessageModule(openIMSDK: OpenIMSDK) {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// sendMessageNotOss: (params: SendMsgParams, opid = uuidV4()) =>
|
sendMessageNotOss: (params: SendMsgParams, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<MessageItem>>((resolve, reject) => {
|
new Promise<BaseResponse<MessageItem>>((resolve, reject) => {
|
||||||
// const offlinePushInfo = params.offlinePushInfo ?? {
|
const offlinePushInfo = params.offlinePushInfo ?? {
|
||||||
// title: 'You has a new message.',
|
title: 'You has a new message.',
|
||||||
// desc: 'You has a new message.',
|
desc: 'You has a new message.',
|
||||||
// ex: '',
|
ex: '',
|
||||||
// iOSPushSound: '+1',
|
iOSPushSound: '+1',
|
||||||
// iOSBadgeCount: true,
|
iOSBadgeCount: true,
|
||||||
// };
|
};
|
||||||
// openIMSDK.libOpenIMSDK.send_message_not_oss(
|
openIMSDK.libOpenIMSDK.send_message_not_oss(
|
||||||
// openIMSDK.baseCallbackWrap<MessageItem>(resolve, reject),
|
openIMSDK.baseCallbackWrap<MessageItem>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// JSON.stringify(params.message),
|
JSON.stringify(params.message),
|
||||||
// params.recvID,
|
params.recvID,
|
||||||
// params.groupID,
|
params.groupID,
|
||||||
// JSON.stringify(offlinePushInfo)
|
JSON.stringify(offlinePushInfo)
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// typingStatusUpdate: (params: TypingUpdateParams, opid = uuidV4()) =>
|
typingStatusUpdate: (params: TypingUpdateParams, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.typing_status_update(
|
openIMSDK.libOpenIMSDK.typing_status_update(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.recvID,
|
params.recvID,
|
||||||
// params.msgTip
|
params.msgTip
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// revokeMessage: (params: OpreateMessageParams, opid = uuidV4()) =>
|
revokeMessage: (params: OpreateMessageParams, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.revoke_message(
|
openIMSDK.libOpenIMSDK.revoke_message(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.conversationID,
|
params.conversationID,
|
||||||
// params.clientMsgID
|
params.clientMsgID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// deleteMessage: (params: OpreateMessageParams, opid = uuidV4()) =>
|
deleteMessage: (params: OpreateMessageParams, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.delete_message(
|
openIMSDK.libOpenIMSDK.delete_message(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// params.conversationID,
|
params.conversationID,
|
||||||
// params.clientMsgID
|
params.clientMsgID
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// deleteMessageFromLocalStorage: (params: OpreateMessageParams, opid = uuidV4()) =>
|
deleteMessageFromLocalStorage: (
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
params: OpreateMessageParams,
|
||||||
// openIMSDK.libOpenIMSDK.delete_message_from_local_storage(
|
opid = uuidV4()
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
) =>
|
||||||
// opid,
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// params.conversationID,
|
openIMSDK.libOpenIMSDK.delete_message_from_local_storage(
|
||||||
// params.clientMsgID
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// );
|
opid,
|
||||||
// }),
|
params.conversationID,
|
||||||
|
params.clientMsgID
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
|
||||||
// deleteAllMsgFromLocal: (opid = uuidV4()) =>
|
deleteAllMsgFromLocal: (opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.delete_all_msg_from_local(
|
openIMSDK.libOpenIMSDK.delete_all_msg_from_local(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// deleteAllMsgFromLocalAndSvr: (opid = uuidV4()) =>
|
deleteAllMsgFromLocalAndSvr: (opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.delete_all_msg_from_local_and_svr(
|
openIMSDK.libOpenIMSDK.delete_all_msg_from_local_and_svr(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// searchLocalMessages: (params: SearchLocalParams, opid = uuidV4()) =>
|
searchLocalMessages: (params: SearchLocalParams, opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<MessageItem[]>>((resolve, reject) => {
|
new Promise<BaseResponse<MessageItem[]>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.search_local_messages(
|
openIMSDK.libOpenIMSDK.search_local_messages(
|
||||||
// openIMSDK.baseCallbackWrap<MessageItem[]>(resolve, reject),
|
openIMSDK.baseCallbackWrap<MessageItem[]>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// JSON.stringify(params)
|
JSON.stringify(params)
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
getAdvancedHistoryMessageList: (
|
getAdvancedHistoryMessageList: (
|
||||||
params: GetAdvancedHistoryMsgParams,
|
params: GetAdvancedHistoryMsgParams,
|
||||||
@@ -353,54 +364,61 @@ export function setupMessageModule(openIMSDK: OpenIMSDK) {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// getAdvancedHistoryMessageListReverse: (
|
getAdvancedHistoryMessageListReverse: (
|
||||||
// params: GetAdvancedHistoryMsgParams, opid = uuidV4()
|
params: GetAdvancedHistoryMsgParams,
|
||||||
// ) =>
|
opid = uuidV4()
|
||||||
// new Promise<BaseResponse<AdvancedGetMessageResult>>((resolve, reject) => {
|
) =>
|
||||||
// openIMSDK.libOpenIMSDK.get_advanced_history_message_list_reverse(
|
new Promise<BaseResponse<AdvancedGetMessageResult>>((resolve, reject) => {
|
||||||
// openIMSDK.baseCallbackWrap<AdvancedGetMessageResult>(resolve, reject),
|
openIMSDK.libOpenIMSDK.get_advanced_history_message_list_reverse(
|
||||||
// opid,
|
openIMSDK.baseCallbackWrap<AdvancedGetMessageResult>(resolve, reject),
|
||||||
// JSON.stringify(params)
|
opid,
|
||||||
// );
|
JSON.stringify(params)
|
||||||
// }),
|
);
|
||||||
// findMessageList: (params: FindMessageParams[], opid = uuidV4()) =>
|
}),
|
||||||
// new Promise<BaseResponse<MessageItem[]>>((resolve, reject) => {
|
findMessageList: (params: FindMessageParams[], opid = uuidV4()) =>
|
||||||
// openIMSDK.libOpenIMSDK.find_message_list(
|
new Promise<BaseResponse<MessageItem[]>>((resolve, reject) => {
|
||||||
// openIMSDK.baseCallbackWrap<MessageItem[]>(resolve, reject),
|
openIMSDK.libOpenIMSDK.find_message_list(
|
||||||
// opid,
|
openIMSDK.baseCallbackWrap<MessageItem[]>(resolve, reject),
|
||||||
// JSON.stringify(params)
|
opid,
|
||||||
// );
|
JSON.stringify(params)
|
||||||
// }),
|
);
|
||||||
// insertGroupMessageToLocalStorage: (params: InsertGroupMsgParams, opid = uuidV4()) =>
|
}),
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
insertGroupMessageToLocalStorage: (
|
||||||
// openIMSDK.libOpenIMSDK.insert_group_message_to_local_storage(
|
params: InsertGroupMsgParams,
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
opid = uuidV4()
|
||||||
// opid,
|
) =>
|
||||||
// JSON.stringify(params.message),
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// params.groupID,
|
openIMSDK.libOpenIMSDK.insert_group_message_to_local_storage(
|
||||||
// params.sendID
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// );
|
opid,
|
||||||
// }),
|
JSON.stringify(params.message),
|
||||||
// insertSingleMessageToLocalStorage: (params: InsertSingleMsgParams, opid = uuidV4()) =>
|
params.groupID,
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
params.sendID
|
||||||
// openIMSDK.libOpenIMSDK.insert_single_message_to_local_storage(
|
);
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
}),
|
||||||
// opid,
|
insertSingleMessageToLocalStorage: (
|
||||||
// JSON.stringify(params.message),
|
params: InsertSingleMsgParams,
|
||||||
// params.recvID,
|
opid = uuidV4()
|
||||||
// params.sendID
|
) =>
|
||||||
// );
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// }),
|
openIMSDK.libOpenIMSDK.insert_single_message_to_local_storage(
|
||||||
// setMessageLocalEx: (params: SetMessageLocalExParams, opid = uuidV4()) =>
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
opid,
|
||||||
// openIMSDK.libOpenIMSDK.set_message_local_ex(
|
JSON.stringify(params.message),
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
params.recvID,
|
||||||
// opid,
|
params.sendID
|
||||||
// params.conversationID,
|
);
|
||||||
// params.clientMsgID,
|
}),
|
||||||
// params.localEx
|
setMessageLocalEx: (params: SetMessageLocalExParams, opid = uuidV4()) =>
|
||||||
// );
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// }),
|
openIMSDK.libOpenIMSDK.set_message_local_ex(
|
||||||
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
|
opid,
|
||||||
|
params.conversationID,
|
||||||
|
params.clientMsgID,
|
||||||
|
params.localEx
|
||||||
|
);
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,12 +507,58 @@ export interface MessageModuleApi {
|
|||||||
params: FileMsgByUrlParams,
|
params: FileMsgByUrlParams,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
getAdvancedHistoryMessageList: (
|
|
||||||
params: GetAdvancedHistoryMsgParams,
|
|
||||||
opid?: string
|
|
||||||
) => Promise<BaseResponse<AdvancedGetMessageResult>>;
|
|
||||||
sendMessage: (
|
sendMessage: (
|
||||||
params: SendMsgParams,
|
params: SendMsgParams,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
|
sendMessageNotOss: (
|
||||||
|
params: SendMsgParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
|
typingStatusUpdate: (
|
||||||
|
params: TypingUpdateParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
revokeMessage: (
|
||||||
|
params: OpreateMessageParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
deleteMessage: (
|
||||||
|
params: OpreateMessageParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
deleteMessageFromLocalStorage: (
|
||||||
|
params: OpreateMessageParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
deleteAllMsgFromLocal: (opid?: string) => Promise<BaseResponse<void>>;
|
||||||
|
deleteAllMsgFromLocalAndSvr: (opid?: string) => Promise<BaseResponse<void>>;
|
||||||
|
searchLocalMessages: (
|
||||||
|
params: SearchLocalParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<MessageItem[]>>;
|
||||||
|
getAdvancedHistoryMessageList: (
|
||||||
|
params: GetAdvancedHistoryMsgParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<AdvancedGetMessageResult>>;
|
||||||
|
getAdvancedHistoryMessageListReverse: (
|
||||||
|
params: GetAdvancedHistoryMsgParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<AdvancedGetMessageResult>>;
|
||||||
|
findMessageList: (
|
||||||
|
params: FindMessageParams[],
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<MessageItem[]>>;
|
||||||
|
insertGroupMessageToLocalStorage: (
|
||||||
|
params: InsertGroupMsgParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
insertSingleMessageToLocalStorage: (
|
||||||
|
params: InsertSingleMsgParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
setMessageLocalEx: (
|
||||||
|
params: SetMessageLocalExParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
import { BaseResponse, SelfUserInfo } from '@/types/entity';
|
import {
|
||||||
|
BaseResponse,
|
||||||
|
FullUserItemWithCache,
|
||||||
|
SelfUserInfo,
|
||||||
|
UserOnlineState,
|
||||||
|
} from '@/types/entity';
|
||||||
import OpenIMSDK from '..';
|
import OpenIMSDK from '..';
|
||||||
import { SetSelfInfoParams } from '@/types/params';
|
import { GetUserInfoWithCacheParams, SetSelfInfoParams } from '@/types/params';
|
||||||
|
import { MessageReceiveOptType } from '@/types/enum';
|
||||||
|
|
||||||
export function setupUserModule(openIMSDK: OpenIMSDK) {
|
export function setupUserModule(openIMSDK: OpenIMSDK) {
|
||||||
return {
|
return {
|
||||||
@@ -22,65 +28,82 @@ export function setupUserModule(openIMSDK: OpenIMSDK) {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// getUsersInfoWithCache: (
|
getUsersInfoWithCache: (
|
||||||
// params: GetUserInfoWithCacheParams,
|
params: GetUserInfoWithCacheParams,
|
||||||
// opid = uuidV4()
|
opid = uuidV4()
|
||||||
// ) =>
|
) =>
|
||||||
// new Promise<BaseResponse<FullUserItemWithCache[]>>((resolve, reject) => {
|
new Promise<BaseResponse<FullUserItemWithCache[]>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.get_users_info_with_cache(
|
openIMSDK.libOpenIMSDK.get_users_info_with_cache(
|
||||||
// openIMSDK.baseCallbackWrap<FullUserItemWithCache[]>(resolve, reject),
|
openIMSDK.baseCallbackWrap<FullUserItemWithCache[]>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// JSON.stringify(params.userIDList),
|
JSON.stringify(params.userIDList),
|
||||||
// params.groupID ?? ''
|
params.groupID ?? ''
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// subscribeUsersStatus: (userIDList: string[], opid = uuidV4()) =>
|
subscribeUsersStatus: (userIDList: string[], opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<UserOnlineState>>((resolve, reject) => {
|
new Promise<BaseResponse<UserOnlineState>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.subscribe_users_status(
|
openIMSDK.libOpenIMSDK.subscribe_users_status(
|
||||||
// openIMSDK.baseCallbackWrap<UserOnlineState>(resolve, reject),
|
openIMSDK.baseCallbackWrap<UserOnlineState>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// JSON.stringify(userIDList)
|
JSON.stringify(userIDList)
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// unsubscribeUsersStatus: (userIDList: string[], opid = uuidV4()) =>
|
unsubscribeUsersStatus: (userIDList: string[], opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.unsubscribe_users_status(
|
openIMSDK.libOpenIMSDK.unsubscribe_users_status(
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// opid,
|
opid,
|
||||||
// JSON.stringify(userIDList)
|
JSON.stringify(userIDList)
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// getSubscribeUsersStatus: (opid = uuidV4()) =>
|
getSubscribeUsersStatus: (opid = uuidV4()) =>
|
||||||
// new Promise<BaseResponse<UserOnlineState[]>>((resolve, reject) => {
|
new Promise<BaseResponse<UserOnlineState[]>>((resolve, reject) => {
|
||||||
// openIMSDK.libOpenIMSDK.get_subscribe_users_status(
|
openIMSDK.libOpenIMSDK.get_subscribe_users_status(
|
||||||
// openIMSDK.baseCallbackWrap<UserOnlineState[]>(resolve, reject),
|
openIMSDK.baseCallbackWrap<UserOnlineState[]>(resolve, reject),
|
||||||
// opid
|
opid
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
|
|
||||||
// setAppBackgroundStatus: (isInBackground: boolean, opid = uuidV4()) =>
|
setGlobalRecvMessageOpt: (
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
msgReceiveOptType: MessageReceiveOptType,
|
||||||
// openIMSDK.libOpenIMSDK.set_app_background_status(
|
opid = uuidV4()
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
) =>
|
||||||
// opid,
|
new Promise<BaseResponse<void>>((resolve, reject) => {
|
||||||
// isInBackground
|
openIMSDK.libOpenIMSDK.set_global_recv_message_opt(
|
||||||
// );
|
openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
||||||
// }),
|
opid,
|
||||||
|
msgReceiveOptType
|
||||||
// setGlobalRecvMessageOpt: (msgReceiveOptType: MessageReceiveOptType, opid = uuidV4()) =>
|
);
|
||||||
// new Promise<BaseResponse<void>>((resolve, reject) => {
|
}),
|
||||||
// openIMSDK.libOpenIMSDK.set_global_recv_message_opt(
|
|
||||||
// openIMSDK.baseCallbackWrap<void>(resolve, reject),
|
|
||||||
// opid,
|
|
||||||
// msgReceiveOptType
|
|
||||||
// );
|
|
||||||
// }),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserModuleApi {
|
export interface UserModuleApi {
|
||||||
getSelfUserInfo: (opid?: string) => Promise<BaseResponse<SelfUserInfo>>;
|
getSelfUserInfo: (opid?: string) => Promise<BaseResponse<SelfUserInfo>>;
|
||||||
|
setSelfInfo: (
|
||||||
|
params: SetSelfInfoParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
getUsersInfoWithCache: (
|
||||||
|
params: GetUserInfoWithCacheParams,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<FullUserItemWithCache[]>>;
|
||||||
|
subscribeUsersStatus: (
|
||||||
|
userIDList: string[],
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<UserOnlineState>>;
|
||||||
|
unsubscribeUsersStatus: (
|
||||||
|
userIDList: string[],
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
|
getSubscribeUsersStatus: (
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<UserOnlineState[]>>;
|
||||||
|
setGlobalRecvMessageOpt: (
|
||||||
|
msgReceiveOptType: MessageReceiveOptType,
|
||||||
|
opid?: string
|
||||||
|
) => Promise<BaseResponse<void>>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { CbEvents } from '@/constant/callback';
|
||||||
import {
|
import {
|
||||||
GroupType,
|
GroupType,
|
||||||
ApplicationHandleResult,
|
ApplicationHandleResult,
|
||||||
@@ -16,6 +17,8 @@ import {
|
|||||||
OnlineState,
|
OnlineState,
|
||||||
} from './enum';
|
} from './enum';
|
||||||
|
|
||||||
|
export type EmitProxy = (event: CbEvents, ...args: any[]) => void;
|
||||||
|
|
||||||
export type BaseCallbackWrap = <T>(
|
export type BaseCallbackWrap = <T>(
|
||||||
resolve: (response: BaseResponse<T>) => void,
|
resolve: (response: BaseResponse<T>) => void,
|
||||||
reject: (response: BaseResponse<T>) => void
|
reject: (response: BaseResponse<T>) => void
|
||||||
|
|||||||
792
src/types/ffi-napi.d.ts
vendored
Normal file
792
src/types/ffi-napi.d.ts
vendored
Normal file
@@ -0,0 +1,792 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/ban-types */
|
||||||
|
|
||||||
|
/// <reference types="node" />
|
||||||
|
declare module '@openim/ffi-napi' {
|
||||||
|
import ref = require('ref-napi');
|
||||||
|
import ref_struct = require('ref-struct-di');
|
||||||
|
import StructType = ref_struct.StructType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a marker type that causes TypeScript to use string literal inference when inferring a generic from an array of {@link ref.TypeLike}.
|
||||||
|
*/
|
||||||
|
export type ArgTypesInferenceMarker = ['void'];
|
||||||
|
|
||||||
|
export interface LibraryFunctionOptions {
|
||||||
|
abi?: number | undefined;
|
||||||
|
async?: boolean | undefined;
|
||||||
|
varargs?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base constraint for an object-based library type definition.
|
||||||
|
*/
|
||||||
|
export type LibraryObjectDefinitionBase = Record<
|
||||||
|
string,
|
||||||
|
[
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
opts?: LibraryFunctionOptions
|
||||||
|
]
|
||||||
|
>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a marker type that causes TypeScript to use string literal inference when inferring a generic from {@link LibraryObjectDefinitionBase}.
|
||||||
|
* If it is not used, `new Library(..., { x: ["int", ["int"]] })` will be inferred as `new Library<{ x: [string, string[]] }>(...)` instead of `new UnionType<{ x: ["int", ["int"]] }>(...)`.
|
||||||
|
*/
|
||||||
|
export type LibraryObjectDefinitionInferenceMarker = Record<
|
||||||
|
string,
|
||||||
|
[retType: 'void', argTypes: ArgTypesInferenceMarker]
|
||||||
|
>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a {@link LibraryObjectDefinitionBase} into a consistent subtype of {@link LibraryDefinitionBase}. If `any` is used, it is passed along
|
||||||
|
* to be interpreted to use a fallback definition for a union.
|
||||||
|
*/
|
||||||
|
export type LibraryObjectDefinitionToLibraryDefinition<
|
||||||
|
T extends LibraryObjectDefinitionBase
|
||||||
|
> = [T] extends [never] | [0]
|
||||||
|
? any // catches T extends never/any (since `0` doesn't overlap with our constraint)
|
||||||
|
: {
|
||||||
|
[P in keyof T]: [
|
||||||
|
retType: ref.CoerceType<T[P][0]>,
|
||||||
|
argTypes: ref.CoerceTypes<T[P][1]>,
|
||||||
|
opts: T[P][2]
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base constraint for a consistent library type definition.
|
||||||
|
*/
|
||||||
|
export type LibraryDefinitionBase = Record<
|
||||||
|
string,
|
||||||
|
[
|
||||||
|
retType: ref.Type,
|
||||||
|
argTypes: ref.Type[],
|
||||||
|
opts: LibraryFunctionOptions | undefined
|
||||||
|
]
|
||||||
|
>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a {@link Library} instance created from a {@link LibraryDefinitionBase}.
|
||||||
|
*/
|
||||||
|
export type LibraryObject<T extends LibraryDefinitionBase> = [T] extends
|
||||||
|
| [never]
|
||||||
|
| [0]
|
||||||
|
? any // catches T extends never/any (since `0` doesn't overlap with our constraint)
|
||||||
|
: {
|
||||||
|
[P in keyof T]: T[P][2] extends undefined
|
||||||
|
? ForeignFunction<
|
||||||
|
ref.UnderlyingType<T[P][0]>,
|
||||||
|
ref.UnderlyingTypes<T[P][1]>
|
||||||
|
>
|
||||||
|
: T[P][2] extends { varargs: true }
|
||||||
|
? VariadicForeignFunction<T[P][0], T[P][1]>
|
||||||
|
: T[P][2] extends { async: true }
|
||||||
|
? ForeignFunction<
|
||||||
|
ref.UnderlyingType<T[P][0]>,
|
||||||
|
ref.UnderlyingTypes<T[P][1]>
|
||||||
|
>['async']
|
||||||
|
: ForeignFunction<
|
||||||
|
ref.UnderlyingType<T[P][0]>,
|
||||||
|
ref.UnderlyingTypes<T[P][1]>
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Provides a friendly API on-top of `DynamicLibrary` and `ForeignFunction`. */
|
||||||
|
export interface Library {
|
||||||
|
/** The extension to use on libraries. */
|
||||||
|
EXT: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param libFile name of library
|
||||||
|
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
|
||||||
|
* @param lib hash that will be extended
|
||||||
|
*/
|
||||||
|
new <
|
||||||
|
TDefinition extends
|
||||||
|
| LibraryObjectDefinitionBase
|
||||||
|
| LibraryObjectDefinitionInferenceMarker,
|
||||||
|
T
|
||||||
|
>(
|
||||||
|
libFile: string | null,
|
||||||
|
funcs: TDefinition,
|
||||||
|
lib: T
|
||||||
|
): T &
|
||||||
|
LibraryObject<LibraryObjectDefinitionToLibraryDefinition<TDefinition>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param libFile name of library
|
||||||
|
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
|
||||||
|
* @param lib hash that will be extended
|
||||||
|
*/
|
||||||
|
new <
|
||||||
|
TDefinition extends
|
||||||
|
| LibraryObjectDefinitionBase
|
||||||
|
| LibraryObjectDefinitionInferenceMarker
|
||||||
|
>(
|
||||||
|
libFile: string | null,
|
||||||
|
funcs: TDefinition,
|
||||||
|
lib?: object
|
||||||
|
): LibraryObject<LibraryObjectDefinitionToLibraryDefinition<TDefinition>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param libFile name of library
|
||||||
|
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
|
||||||
|
* @param lib hash that will be extended
|
||||||
|
*/
|
||||||
|
new (
|
||||||
|
libFile: string | null,
|
||||||
|
funcs?: Record<
|
||||||
|
string,
|
||||||
|
[
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
opts?: LibraryFunctionOptions
|
||||||
|
]
|
||||||
|
>,
|
||||||
|
lib?: object
|
||||||
|
): any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param libFile name of library
|
||||||
|
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
|
||||||
|
* @param lib hash that will be extended
|
||||||
|
*/
|
||||||
|
<
|
||||||
|
TDefinition extends
|
||||||
|
| LibraryObjectDefinitionBase
|
||||||
|
| LibraryObjectDefinitionInferenceMarker,
|
||||||
|
T
|
||||||
|
>(
|
||||||
|
libFile: string | null,
|
||||||
|
funcs: TDefinition,
|
||||||
|
lib: T
|
||||||
|
): T &
|
||||||
|
LibraryObject<LibraryObjectDefinitionToLibraryDefinition<TDefinition>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param libFile name of library
|
||||||
|
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
|
||||||
|
* @param lib hash that will be extended
|
||||||
|
*/
|
||||||
|
<
|
||||||
|
TDefinition extends
|
||||||
|
| LibraryObjectDefinitionBase
|
||||||
|
| LibraryObjectDefinitionInferenceMarker
|
||||||
|
>(
|
||||||
|
libFile: string | null,
|
||||||
|
funcs: TDefinition,
|
||||||
|
lib?: object
|
||||||
|
): LibraryObject<LibraryObjectDefinitionToLibraryDefinition<TDefinition>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param libFile name of library
|
||||||
|
* @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}]
|
||||||
|
* @param lib hash that will be extended
|
||||||
|
*/
|
||||||
|
(
|
||||||
|
libFile: string | null,
|
||||||
|
funcs?: Record<
|
||||||
|
string,
|
||||||
|
[
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
opts?: LibraryFunctionOptions
|
||||||
|
]
|
||||||
|
>,
|
||||||
|
lib?: object
|
||||||
|
): any;
|
||||||
|
}
|
||||||
|
export const Library: Library;
|
||||||
|
|
||||||
|
/** Get value of errno. */
|
||||||
|
export function errno(): number;
|
||||||
|
|
||||||
|
export interface Function<
|
||||||
|
TReturnType extends ref.Type = ref.Type,
|
||||||
|
TArgTypes extends ref.Type[] = ref.Type[]
|
||||||
|
> extends ref.Type<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
> {
|
||||||
|
/** The type of return value. */
|
||||||
|
retType: TReturnType;
|
||||||
|
/** The type of arguments. */
|
||||||
|
argTypes: TArgTypes;
|
||||||
|
/** Is set for node-ffi functions. */
|
||||||
|
ffi_type: PFFI_TYPE;
|
||||||
|
abi: number;
|
||||||
|
|
||||||
|
/** Get a `Callback` pointer of this function type. */
|
||||||
|
toPointer(
|
||||||
|
fn: (
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
/** Get a `ForeignFunction` of this function type. */
|
||||||
|
toFunction(
|
||||||
|
buf: Buffer
|
||||||
|
): ForeignFunction<
|
||||||
|
ref.UnderlyingType<TReturnType>,
|
||||||
|
ref.UnderlyingTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates and returns a type for a C function pointer. */
|
||||||
|
export const Function: {
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): Function<ref.CoerceType<TReturnType>, ref.CoerceTypes<TArgTypes>>;
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.TypeLike,
|
||||||
|
TArgTypes extends ref.TypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): Function<ref.CoerceType<TReturnType>, ref.CoerceTypes<TArgTypes>>;
|
||||||
|
|
||||||
|
new (
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
abi?: number
|
||||||
|
): Function;
|
||||||
|
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
<
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): Function<ref.CoerceType<TReturnType>, ref.CoerceTypes<TArgTypes>>;
|
||||||
|
<
|
||||||
|
TReturnType extends ref.TypeLike,
|
||||||
|
TArgTypes extends ref.Type[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): Function<ref.CoerceType<TReturnType>, ref.CoerceTypes<TArgTypes>>;
|
||||||
|
|
||||||
|
(retType: ref.TypeLike, argTypes: ref.TypeLike[], abi?: number): Function;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface ForeignFunction<TReturn = any, TArgs extends any[] = any[]> {
|
||||||
|
(...args: TArgs): TReturn;
|
||||||
|
async(...args: [...TArgs, (err: any, value: TReturn) => void]): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a foreign function in another library. Manages all of the aspects
|
||||||
|
* of function execution, including marshalling the data parameters for the
|
||||||
|
* function into native types and also unmarshalling the return from function
|
||||||
|
* execution.
|
||||||
|
*/
|
||||||
|
export const ForeignFunction: {
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.NamedType,
|
||||||
|
TArgTypes extends ref.TypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): ForeignFunction<
|
||||||
|
ref.UnderlyingType<TReturnType>,
|
||||||
|
ref.UnderlyingTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.TypeLike,
|
||||||
|
TArgTypes extends ref.TypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): ForeignFunction<
|
||||||
|
ref.UnderlyingType<TReturnType>,
|
||||||
|
ref.UnderlyingTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
|
||||||
|
new (
|
||||||
|
ptr: Buffer,
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
abi?: number
|
||||||
|
): ForeignFunction;
|
||||||
|
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
<
|
||||||
|
TReturnType extends ref.NamedType,
|
||||||
|
TArgTypes extends ref.TypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): ForeignFunction<
|
||||||
|
ref.UnderlyingType<TReturnType>,
|
||||||
|
ref.UnderlyingTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
<
|
||||||
|
TReturnType extends ref.TypeLike,
|
||||||
|
TArgTypes extends ref.TypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): ForeignFunction<
|
||||||
|
ref.UnderlyingType<TReturnType>,
|
||||||
|
ref.UnderlyingTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
|
||||||
|
(
|
||||||
|
ptr: Buffer,
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
abi?: number
|
||||||
|
): ForeignFunction;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface VariadicForeignFunction<
|
||||||
|
TReturnType extends ref.Type = ref.Type,
|
||||||
|
TArgTypes extends ref.Type[] = ref.Type[]
|
||||||
|
> {
|
||||||
|
/**
|
||||||
|
* What gets returned is another function that needs to be invoked with the rest
|
||||||
|
* of the variadic types that are being invoked from the function.
|
||||||
|
*/
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
<A extends ref.NamedTypeLike[]>(...args: A): ForeignFunction<
|
||||||
|
ref.UnderlyingType<TReturnType>,
|
||||||
|
[...ref.UnderlyingTypes<TArgTypes>, ...ref.UnderlyingTypes<A>]
|
||||||
|
>;
|
||||||
|
/**
|
||||||
|
* What gets returned is another function that needs to be invoked with the rest
|
||||||
|
* of the variadic types that are being invoked from the function.
|
||||||
|
*/
|
||||||
|
<A extends ref.TypeLike[]>(...args: A): ForeignFunction<
|
||||||
|
ref.UnderlyingType<TReturnType>,
|
||||||
|
[...ref.UnderlyingTypes<TArgTypes>, ...ref.UnderlyingTypes<A>]
|
||||||
|
>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return type as a property of the function generator to
|
||||||
|
* allow for monkey patching the return value in the very rare case where the
|
||||||
|
* return type is variadic as well
|
||||||
|
*/
|
||||||
|
returnType: TReturnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For when you want to call to a C function with variable amount of arguments.
|
||||||
|
* i.e. `printf`.
|
||||||
|
*
|
||||||
|
* This function takes care of caching and reusing `ForeignFunction` instances that
|
||||||
|
* contain the same ffi_type argument signature.
|
||||||
|
*/
|
||||||
|
export const VariadicForeignFunction: {
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
ret: TReturnType,
|
||||||
|
fixedArgs: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): VariadicForeignFunction<
|
||||||
|
ref.CoerceType<TReturnType>,
|
||||||
|
ref.CoerceTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.TypeLike,
|
||||||
|
TArgTypes extends ref.TypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
ret: TReturnType,
|
||||||
|
fixedArgs: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): VariadicForeignFunction<
|
||||||
|
ref.CoerceType<TReturnType>,
|
||||||
|
ref.CoerceTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
|
||||||
|
new (
|
||||||
|
ptr: Buffer,
|
||||||
|
ret: ref.TypeLike,
|
||||||
|
fixedArgs: ref.TypeLike[],
|
||||||
|
abi?: number
|
||||||
|
): VariadicForeignFunction;
|
||||||
|
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
<
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
ret: TReturnType,
|
||||||
|
fixedArgs: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): VariadicForeignFunction<
|
||||||
|
ref.CoerceType<TReturnType>,
|
||||||
|
ref.CoerceTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
<
|
||||||
|
TReturnType extends ref.TypeLike,
|
||||||
|
TArgTypes extends ref.TypeLike[] | ArgTypesInferenceMarker
|
||||||
|
>(
|
||||||
|
ptr: Buffer,
|
||||||
|
ret: TReturnType,
|
||||||
|
fixedArgs: TArgTypes,
|
||||||
|
abi?: number
|
||||||
|
): VariadicForeignFunction<
|
||||||
|
ref.CoerceType<TReturnType>,
|
||||||
|
ref.CoerceTypes<TArgTypes>
|
||||||
|
>;
|
||||||
|
|
||||||
|
(
|
||||||
|
ptr: Buffer,
|
||||||
|
ret: ref.TypeLike,
|
||||||
|
fixedArgs: ref.TypeLike[],
|
||||||
|
abi?: number
|
||||||
|
): VariadicForeignFunction;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class loads and fetches function pointers for dynamic libraries
|
||||||
|
* (`.so`, `.dylib`, `etc`). After the libray's function pointer is acquired, then you
|
||||||
|
* call {@link DynamicLibrary.get} to retreive a pointer to an exported symbol. You need to
|
||||||
|
* call `get___` on the pointer to dereference it into its actual value, or
|
||||||
|
* turn the pointer into a callable function with {@link ForeignFunction}.
|
||||||
|
*/
|
||||||
|
export class DynamicLibrary {
|
||||||
|
/**
|
||||||
|
* @param mode One of the numeric {@link DynamicLibrary.FLAGS} values.
|
||||||
|
*/
|
||||||
|
constructor(path?: string, mode?: number);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close library, returns the result of the `dlclose` system function.
|
||||||
|
*/
|
||||||
|
close(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a symbol from this library.
|
||||||
|
*/
|
||||||
|
get(symbol: string): Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the result of the `dlerror` system function.
|
||||||
|
*/
|
||||||
|
error(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path originally passed to the constructor.
|
||||||
|
*/
|
||||||
|
path(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class loads and fetches function pointers for dynamic libraries
|
||||||
|
* (`.so`, `.dylib`, etc). After the libray's function pointer is acquired, then you
|
||||||
|
* call {@link DynamicLibrary.get} to retreive a pointer to an exported symbol. You need to
|
||||||
|
* call `get___` on the pointer to dereference it into its actual value, or
|
||||||
|
* turn the pointer into a callable function with {@link ForeignFunction}.
|
||||||
|
*
|
||||||
|
* @param mode One of the numeric {@link DynamicLibrary.FLAGS} values.
|
||||||
|
*/
|
||||||
|
export function DynamicLibrary(path?: string, mode?: number): DynamicLibrary;
|
||||||
|
export namespace DynamicLibrary {
|
||||||
|
/**
|
||||||
|
* Exported flags from "dlfcn.h"
|
||||||
|
*/
|
||||||
|
namespace FLAGS {
|
||||||
|
// flags for dlopen()
|
||||||
|
const RTLD_LAZY: number;
|
||||||
|
const RTLD_NOW: number;
|
||||||
|
const RTLD_LOCAL: number;
|
||||||
|
const RTLD_GLOBAL: number;
|
||||||
|
const RTLD_NOLOAD: number | undefined; // not defined on Windows
|
||||||
|
const RTLD_NODELETE: number | undefined; // not defined on Windows
|
||||||
|
const RTLD_FIRST: number | undefined; // not defined on Windows
|
||||||
|
|
||||||
|
// flags for dlsym()
|
||||||
|
const RTLD_NEXT: ref.Pointer<unknown>;
|
||||||
|
const RTLD_DEFAULT: ref.Pointer<unknown>;
|
||||||
|
const RTLD_SELF: ref.Pointer<unknown> | undefined; // not defined on Windows
|
||||||
|
const RTLD_MAIN_ONLY: ref.Pointer<unknown> | undefined; // not defined on Windows
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns a JavaScript function into a C function pointer.
|
||||||
|
* The function pointer may be used in other C functions that
|
||||||
|
* accept C callback functions.
|
||||||
|
*/
|
||||||
|
export interface Callback {
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[]
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi: number,
|
||||||
|
fn: (
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
new <TReturnType extends ref.TypeLike, TArgTypes extends ref.TypeLike[]>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi: number,
|
||||||
|
fn: (
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
new <
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[]
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
fn: (
|
||||||
|
...ags: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
new <TReturnType extends ref.TypeLike, TArgTypes extends ref.TypeLike[]>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
fn: (
|
||||||
|
...ags: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
|
||||||
|
new (
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
abi: number,
|
||||||
|
fn: (...args: any[]) => any
|
||||||
|
): Buffer;
|
||||||
|
new (
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
fn: (...args: any[]) => any
|
||||||
|
): Buffer;
|
||||||
|
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
<
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[]
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi: number,
|
||||||
|
fn: (
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
<TReturnType extends ref.TypeLike, TArgTypes extends ref.TypeLike[]>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
abi: number,
|
||||||
|
fn: (
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
|
||||||
|
// NOTE: This overload is a subtype of the next overload, but provides better completions.
|
||||||
|
<
|
||||||
|
TReturnType extends ref.NamedTypeLike,
|
||||||
|
TArgTypes extends ref.NamedTypeLike[]
|
||||||
|
>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
fn: (
|
||||||
|
...ags: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
<TReturnType extends ref.TypeLike, TArgTypes extends ref.TypeLike[]>(
|
||||||
|
retType: TReturnType,
|
||||||
|
argTypes: TArgTypes,
|
||||||
|
fn: (
|
||||||
|
...ags: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
): ref.Pointer<
|
||||||
|
(
|
||||||
|
...args: ref.UnderlyingTypes<TArgTypes>
|
||||||
|
) => ref.UnderlyingType<TReturnType>
|
||||||
|
>;
|
||||||
|
|
||||||
|
(
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
abi: number,
|
||||||
|
fn: (...args: any[]) => any
|
||||||
|
): Buffer;
|
||||||
|
(
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
argTypes: ref.TypeLike[],
|
||||||
|
fn: (...args: any[]) => any
|
||||||
|
): Buffer;
|
||||||
|
}
|
||||||
|
export const Callback: Callback;
|
||||||
|
|
||||||
|
/** Get a `ffi_type *` Buffer appropriate for the given type. */
|
||||||
|
export function ffiType(type: ref.TypeLike): ref.Pointer<FFI_TYPE>;
|
||||||
|
export namespace ffiType {
|
||||||
|
/**
|
||||||
|
* Define the `ffi_type` struct (see deps/libffi/include/ffi.h) for use in JS.
|
||||||
|
* This struct type is used internally to define custom struct ret/arg types.
|
||||||
|
*/
|
||||||
|
const FFI_TYPE: StructType<{
|
||||||
|
size: typeof ref.types.size_t;
|
||||||
|
alignment: typeof ref.types.ushort;
|
||||||
|
type: typeof ref.types.ushort;
|
||||||
|
elements: ref.Type<ref.Pointer<PFFI_TYPE>>;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
type FFI_TYPE = ReturnType<typeof FFI_TYPE>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CIF(
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
types: ref.TypeLike[],
|
||||||
|
abi?: number
|
||||||
|
): Buffer;
|
||||||
|
export function CIF_var(
|
||||||
|
retType: ref.TypeLike,
|
||||||
|
types: ref.TypeLike[],
|
||||||
|
numFixedArgs: number,
|
||||||
|
abi?: number
|
||||||
|
): Buffer;
|
||||||
|
|
||||||
|
export const HAS_OBJC: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an opaque pointer to an {@link FFI_TYPE} struct used for marshalling types to native code.
|
||||||
|
*/
|
||||||
|
export type PFFI_TYPE = ref.Pointer<FFI_TYPE>;
|
||||||
|
|
||||||
|
// declare module 'ref-napi' {
|
||||||
|
// interface Type {
|
||||||
|
// /**
|
||||||
|
// * Determines the FFI_TYPE set for a type.
|
||||||
|
// */
|
||||||
|
// ffi_type?: PFFI_TYPE | undefined;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
export interface FfiTypesRegistry {
|
||||||
|
void: PFFI_TYPE;
|
||||||
|
uint8: PFFI_TYPE;
|
||||||
|
int8: PFFI_TYPE;
|
||||||
|
uint16: PFFI_TYPE;
|
||||||
|
int16: PFFI_TYPE;
|
||||||
|
uint32: PFFI_TYPE;
|
||||||
|
int32: PFFI_TYPE;
|
||||||
|
uint64: PFFI_TYPE;
|
||||||
|
int64: PFFI_TYPE;
|
||||||
|
uchar: PFFI_TYPE;
|
||||||
|
char: PFFI_TYPE;
|
||||||
|
ushort: PFFI_TYPE;
|
||||||
|
short: PFFI_TYPE;
|
||||||
|
uint: PFFI_TYPE;
|
||||||
|
int: PFFI_TYPE;
|
||||||
|
float: PFFI_TYPE;
|
||||||
|
double: PFFI_TYPE;
|
||||||
|
pointer: PFFI_TYPE;
|
||||||
|
ulonglong: PFFI_TYPE;
|
||||||
|
longlong: PFFI_TYPE;
|
||||||
|
ulong: PFFI_TYPE;
|
||||||
|
long: PFFI_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FFI_TYPES: FfiTypesRegistry;
|
||||||
|
export const FFI_OK: number;
|
||||||
|
export const FFI_BAD_TYPEDEF: number;
|
||||||
|
export const FFI_BAD_ABI: number;
|
||||||
|
export const FFI_DEFAULT_ABI: number;
|
||||||
|
export const FFI_FIRST_ABI: number;
|
||||||
|
export const FFI_LAST_ABI: number;
|
||||||
|
|
||||||
|
// NOTE: These are defined depending on the platform ffi-napi was compiled on:
|
||||||
|
export const FFI_SYSV: number | undefined; // __arm__, Intel x86 Win32, __aarch64__, Intel x86 and AMD x86/x64
|
||||||
|
export const FFI_VFP: number | undefined; // __arm__
|
||||||
|
export const FFI_UNIX64: number | undefined; // All unix variants
|
||||||
|
export const FFI_STDCALL: number | undefined; // Intel x86 Win32
|
||||||
|
export const FFI_THISCALL: number | undefined; // Intel x86 Win32
|
||||||
|
export const FFI_FASTCALL: number | undefined; // Intel x86 Win32
|
||||||
|
export const FFI_MS_CDECL: number | undefined; // Intel x86 Win32
|
||||||
|
export const FFI_WIN64: number | undefined; // Intel x86 Win64
|
||||||
|
|
||||||
|
export import RTLD_LAZY = DynamicLibrary.FLAGS.RTLD_LAZY;
|
||||||
|
export import RTLD_NOW = DynamicLibrary.FLAGS.RTLD_NOW;
|
||||||
|
export import RTLD_LOCAL = DynamicLibrary.FLAGS.RTLD_LOCAL;
|
||||||
|
export import RTLD_GLOBAL = DynamicLibrary.FLAGS.RTLD_GLOBAL;
|
||||||
|
export import RTLD_NOLOAD = DynamicLibrary.FLAGS.RTLD_NOLOAD;
|
||||||
|
export import RTLD_NODELETE = DynamicLibrary.FLAGS.RTLD_NODELETE;
|
||||||
|
export import RTLD_FIRST = DynamicLibrary.FLAGS.RTLD_FIRST;
|
||||||
|
export import RTLD_NEXT = DynamicLibrary.FLAGS.RTLD_NEXT;
|
||||||
|
export import RTLD_DEFAULT = DynamicLibrary.FLAGS.RTLD_DEFAULT;
|
||||||
|
export import RTLD_SELF = DynamicLibrary.FLAGS.RTLD_SELF;
|
||||||
|
export import RTLD_MAIN_ONLY = DynamicLibrary.FLAGS.RTLD_MAIN_ONLY;
|
||||||
|
|
||||||
|
export const FFI_ARG_SIZE: number;
|
||||||
|
export const FFI_SARG_SIZE: number;
|
||||||
|
export const FFI_TYPE_SIZE: number;
|
||||||
|
export const FFI_CIF_SIZE: number;
|
||||||
|
|
||||||
|
export const LIB_EXT: string;
|
||||||
|
|
||||||
|
export import FFI_TYPE = ffiType.FFI_TYPE;
|
||||||
|
|
||||||
|
/** Default types. */
|
||||||
|
export import types = ref.types;
|
||||||
|
}
|
||||||
229
src/types/libOpenIMSDK.d.ts
vendored
229
src/types/libOpenIMSDK.d.ts
vendored
@@ -33,15 +33,18 @@ declare module 'libOpenIMSDK' {
|
|||||||
login(
|
login(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
userID: string,
|
uid: string,
|
||||||
token: string
|
token: string
|
||||||
): void;
|
): void;
|
||||||
logout(cCallback: CB_S_I_S_S, operationID: string): void;
|
logout(cCallback: CB_S_I_S_S, operationID: string): void;
|
||||||
|
set_app_background_status(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
isBackground: number
|
||||||
|
): void;
|
||||||
network_status_changed(cCallback: CB_S_I_S_S, operationID: string): void;
|
network_status_changed(cCallback: CB_S_I_S_S, operationID: string): void;
|
||||||
get_login_status(operationID: string): number;
|
get_login_status(operationID: string): number;
|
||||||
get_login_user(): string;
|
get_login_user(): string;
|
||||||
|
|
||||||
// message related functions
|
|
||||||
create_text_message(operationID: string, text: string): string;
|
create_text_message(operationID: string, text: string): string;
|
||||||
create_advanced_text_message(
|
create_advanced_text_message(
|
||||||
operationID: string,
|
operationID: string,
|
||||||
@@ -103,6 +106,7 @@ declare module 'libOpenIMSDK' {
|
|||||||
create_image_message(operationID: string, imagePath: string): string;
|
create_image_message(operationID: string, imagePath: string): string;
|
||||||
create_image_message_by_url(
|
create_image_message_by_url(
|
||||||
operationID: string,
|
operationID: string,
|
||||||
|
sourcePath: string,
|
||||||
sourcePicture: string,
|
sourcePicture: string,
|
||||||
bigPicture: string,
|
bigPicture: string,
|
||||||
snapshotPicture: string
|
snapshotPicture: string
|
||||||
@@ -148,11 +152,91 @@ declare module 'libOpenIMSDK' {
|
|||||||
data: string
|
data: string
|
||||||
): string;
|
): string;
|
||||||
create_forward_message(operationID: string, m: string): string;
|
create_forward_message(operationID: string, m: string): string;
|
||||||
get_advanced_history_message_list(
|
get_all_conversation_list(cCallback: CB_S_I_S_S, operationID: string): void;
|
||||||
|
get_conversation_list_split(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
getMessageOptions: string
|
offset: number,
|
||||||
|
count: number
|
||||||
): void;
|
): void;
|
||||||
|
get_one_conversation(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
sessionType: number,
|
||||||
|
sourceID: string
|
||||||
|
): void;
|
||||||
|
get_multiple_conversation(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationIDList: string
|
||||||
|
): void;
|
||||||
|
set_conversation_msg_destruct_time(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
msgDestructTime: number
|
||||||
|
): void;
|
||||||
|
set_conversation_is_msg_destruct(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
isMsgDestruct: number
|
||||||
|
): void;
|
||||||
|
hide_conversation(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string
|
||||||
|
): void;
|
||||||
|
get_conversation_recv_message_opt(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationIDList: string
|
||||||
|
): void;
|
||||||
|
set_conversation_draft(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
draftText: string
|
||||||
|
): void;
|
||||||
|
reset_conversation_group_at_type(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string
|
||||||
|
): void;
|
||||||
|
pin_conversation(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
isPinned: number
|
||||||
|
): void;
|
||||||
|
set_conversation_private_chat(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
isPrivate: number
|
||||||
|
): void;
|
||||||
|
set_conversation_burn_duration(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
duration: number
|
||||||
|
): void;
|
||||||
|
set_conversation_recv_message_opt(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
opt: number
|
||||||
|
): void;
|
||||||
|
get_total_unread_msg_count(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string
|
||||||
|
): void;
|
||||||
|
get_at_all_tag(operationID: string): string;
|
||||||
|
get_conversation_id_by_session_type(
|
||||||
|
operationID: string,
|
||||||
|
sourceID: string,
|
||||||
|
sessionType: number
|
||||||
|
): string;
|
||||||
send_message(
|
send_message(
|
||||||
cCallback: CB_S_I_S_S_I,
|
cCallback: CB_S_I_S_S_I,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
@@ -161,31 +245,142 @@ declare module 'libOpenIMSDK' {
|
|||||||
groupID: string,
|
groupID: string,
|
||||||
offlinePushInfo: string
|
offlinePushInfo: string
|
||||||
): void;
|
): void;
|
||||||
|
send_message_not_oss(
|
||||||
// Conversation related functions
|
cCallback: CB_S_I_S_S_I,
|
||||||
get_all_conversation_list(cCallback: CB_S_I_S_S, operationID: string): void;
|
operationID: string,
|
||||||
|
message: string,
|
||||||
// User related functions
|
recvID: string,
|
||||||
|
groupID: string,
|
||||||
|
offlinePushInfo: string
|
||||||
|
): void;
|
||||||
|
find_message_list(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
findMessageOptions: string
|
||||||
|
): void;
|
||||||
|
get_advanced_history_message_list(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
getMessageOptions: string
|
||||||
|
): void;
|
||||||
|
get_advanced_history_message_list_reverse(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
getMessageOptions: string
|
||||||
|
): void;
|
||||||
|
revoke_message(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
clientMsgID: string
|
||||||
|
): void;
|
||||||
|
typing_status_update(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
recvID: string,
|
||||||
|
msgTip: string
|
||||||
|
): void;
|
||||||
|
mark_conversation_message_as_read(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string
|
||||||
|
): void;
|
||||||
|
delete_message_from_local_storage(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
clientMsgID: string
|
||||||
|
): void;
|
||||||
|
delete_message(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
clientMsgID: string
|
||||||
|
): void;
|
||||||
|
hide_all_conversations(cCallback: CB_S_I_S_S, operationID: string): void;
|
||||||
|
delete_all_msg_from_local_and_svr(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string
|
||||||
|
): void;
|
||||||
|
delete_all_msg_from_local(cCallback: CB_S_I_S_S, operationID: string): void;
|
||||||
|
clear_conversation_and_delete_all_msg(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string
|
||||||
|
): void;
|
||||||
|
delete_conversation_and_delete_all_msg(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string
|
||||||
|
): void;
|
||||||
|
insert_single_message_to_local_storage(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
message: string,
|
||||||
|
recvID: string,
|
||||||
|
sendID: string
|
||||||
|
): void;
|
||||||
|
insert_group_message_to_local_storage(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
message: string,
|
||||||
|
groupID: string,
|
||||||
|
sendID: string
|
||||||
|
): void;
|
||||||
|
search_local_messages(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
searchParam: string
|
||||||
|
): void;
|
||||||
|
set_message_local_ex(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
conversationID: string,
|
||||||
|
clientMsgID: string,
|
||||||
|
localEx: string
|
||||||
|
): void;
|
||||||
get_users_info(
|
get_users_info(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
userIDList: string
|
userIDs: string
|
||||||
|
): void;
|
||||||
|
get_users_info_with_cache(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
userIDs: string,
|
||||||
|
groupID: string
|
||||||
|
): void;
|
||||||
|
get_users_info_from_srv(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
userIDs: string
|
||||||
): void;
|
): void;
|
||||||
set_self_info(
|
set_self_info(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
userInfo: string
|
userInfo: string
|
||||||
): void;
|
): void;
|
||||||
|
set_global_recv_message_opt(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
opt: number
|
||||||
|
): void;
|
||||||
get_self_user_info(cCallback: CB_S_I_S_S, operationID: string): void;
|
get_self_user_info(cCallback: CB_S_I_S_S, operationID: string): void;
|
||||||
|
update_msg_sender_info(
|
||||||
|
cCallback: CB_S_I_S_S,
|
||||||
|
operationID: string,
|
||||||
|
nickname: string,
|
||||||
|
faceURL: string
|
||||||
|
): void;
|
||||||
subscribe_users_status(
|
subscribe_users_status(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
userIDList: string
|
userIDs: string
|
||||||
): void;
|
): void;
|
||||||
unsubscribe_users_status(
|
unsubscribe_users_status(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
userIDList: string
|
userIDs: string
|
||||||
): void;
|
): void;
|
||||||
get_subscribe_users_status(
|
get_subscribe_users_status(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
@@ -194,10 +389,9 @@ declare module 'libOpenIMSDK' {
|
|||||||
get_user_status(
|
get_user_status(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
userIDList: string
|
userIDs: string
|
||||||
): void;
|
): void;
|
||||||
|
// Friend functions
|
||||||
// Friend related functions
|
|
||||||
get_specified_friends_info(
|
get_specified_friends_info(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
@@ -264,8 +458,7 @@ declare module 'libOpenIMSDK' {
|
|||||||
operationID: string,
|
operationID: string,
|
||||||
removeUserID: string
|
removeUserID: string
|
||||||
): void;
|
): void;
|
||||||
|
// Group functions
|
||||||
// Group related functions
|
|
||||||
create_group(
|
create_group(
|
||||||
cCallback: CB_S_I_S_S,
|
cCallback: CB_S_I_S_S,
|
||||||
operationID: string,
|
operationID: string,
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ export type AccessFriendParams = {
|
|||||||
handleMsg: string;
|
handleMsg: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type AddFriendParams = {
|
||||||
|
toUserID: string;
|
||||||
|
reqMsg: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type SearchFriendParams = {
|
export type SearchFriendParams = {
|
||||||
keywordList: string[];
|
keywordList: string[];
|
||||||
isSearchUserID: boolean;
|
isSearchUserID: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user