chore: add assets & handle enterprise func
This commit is contained in:
BIN
assets/linux_arm64/libopenimsdk.so
Normal file
BIN
assets/linux_arm64/libopenimsdk.so
Normal file
Binary file not shown.
BIN
assets/linux_x64/libopenimsdk.so
Normal file
BIN
assets/linux_x64/libopenimsdk.so
Normal file
Binary file not shown.
0
assets/mac_arm64/.gitkeep
Normal file
0
assets/mac_arm64/.gitkeep
Normal file
BIN
assets/mac_arm64/libopenimsdk.dylib
Executable file → Normal file
BIN
assets/mac_arm64/libopenimsdk.dylib
Executable file → Normal file
Binary file not shown.
BIN
assets/mac_x64/libopenimsdk.dylib
Normal file
BIN
assets/mac_x64/libopenimsdk.dylib
Normal file
Binary file not shown.
BIN
assets/win_ia32/libopenimsdk.dll
Normal file
BIN
assets/win_ia32/libopenimsdk.dll
Normal file
Binary file not shown.
BIN
assets/win_x64/libopenimsdk.dll
Normal file
BIN
assets/win_x64/libopenimsdk.dll
Normal file
Binary file not shown.
10
package-lock.json
generated
10
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@openim/node-client-sdk",
|
"name": "@openim/electron-client-sdk",
|
||||||
"version": "1.0.7",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@openim/node-client-sdk",
|
"name": "@openim/electron-client-sdk",
|
||||||
"version": "1.0.7",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"koffi": "^2.8.0",
|
"koffi": "^2.8.0",
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"electron": ">=12.0.0",
|
"electron": ">=12.0.0",
|
||||||
"open-im-sdk-wasm": "^3.5.3-alpha.2"
|
"open-im-sdk-wasm": "^3.5.3-alpha.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@aashutoshrathi/word-wrap": {
|
"node_modules/@aashutoshrathi/word-wrap": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openim/electron-client-sdk",
|
"name": "@openim/electron-client-sdk",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "open im sdk for node",
|
"description": "open im sdk for node",
|
||||||
"source": "src/index.ts",
|
"source": "src/index.ts",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
|
|||||||
@@ -45,9 +45,11 @@ class OpenIMSDK
|
|||||||
sendMessageCallbackProto: koffi.IKoffiCType;
|
sendMessageCallbackProto: koffi.IKoffiCType;
|
||||||
listenerCallback: koffi.IKoffiRegisteredCallback;
|
listenerCallback: koffi.IKoffiRegisteredCallback;
|
||||||
lib: koffi.IKoffiLib;
|
lib: koffi.IKoffiLib;
|
||||||
|
enterprise: boolean;
|
||||||
|
|
||||||
constructor(libPath: string, emitProxy?: EmitProxy) {
|
constructor(libPath: string, emitProxy?: EmitProxy, enterprise = false) {
|
||||||
super();
|
super();
|
||||||
|
this.enterprise = enterprise;
|
||||||
this.lib = koffi.load(libPath);
|
this.lib = koffi.load(libPath);
|
||||||
this.baseCallbackProto = koffi.proto('__stdcall', 'baseCallback', 'void', [
|
this.baseCallbackProto = koffi.proto('__stdcall', 'baseCallback', 'void', [
|
||||||
'str',
|
'str',
|
||||||
@@ -67,12 +69,6 @@ class OpenIMSDK
|
|||||||
'void',
|
'void',
|
||||||
['int', 'str']
|
['int', 'str']
|
||||||
);
|
);
|
||||||
|
|
||||||
if (emitProxy) {
|
|
||||||
// @ts-ignore eslint-disable-next-line
|
|
||||||
this.emit = emitProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.listenerCallback = koffi.register(
|
this.listenerCallback = koffi.register(
|
||||||
(event: NativeEvent, data: string) => {
|
(event: NativeEvent, data: string) => {
|
||||||
const cbEvent = eventMapping[event];
|
const cbEvent = eventMapping[event];
|
||||||
@@ -82,6 +78,22 @@ class OpenIMSDK
|
|||||||
koffi.pointer(listenerCallbackProto)
|
koffi.pointer(listenerCallbackProto)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (emitProxy) {
|
||||||
|
// @ts-ignore eslint-disable-next-line
|
||||||
|
this.emit = emitProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.registerFunc();
|
||||||
|
|
||||||
|
Object.assign(this, setupUserModule(this));
|
||||||
|
Object.assign(this, setupFriendModule(this));
|
||||||
|
Object.assign(this, setupGroupModule(this));
|
||||||
|
Object.assign(this, setupConversationModule(this));
|
||||||
|
Object.assign(this, setupMessageModule(this));
|
||||||
|
Object.assign(this, setupSignalingModule(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
registerFunc = () => {
|
||||||
this.libOpenIMSDK.set_group_listener = this.lib.func(
|
this.libOpenIMSDK.set_group_listener = this.lib.func(
|
||||||
'__stdcall',
|
'__stdcall',
|
||||||
'set_group_listener',
|
'set_group_listener',
|
||||||
@@ -124,12 +136,6 @@ class OpenIMSDK
|
|||||||
'void',
|
'void',
|
||||||
['listenerCallback *']
|
['listenerCallback *']
|
||||||
);
|
);
|
||||||
this.libOpenIMSDK.set_signaling_listener = this.lib.func(
|
|
||||||
'__stdcall',
|
|
||||||
'set_signaling_listener',
|
|
||||||
'void',
|
|
||||||
['listenerCallback *']
|
|
||||||
);
|
|
||||||
this.libOpenIMSDK.init_sdk = this.lib.func(
|
this.libOpenIMSDK.init_sdk = this.lib.func(
|
||||||
'__stdcall',
|
'__stdcall',
|
||||||
'init_sdk',
|
'init_sdk',
|
||||||
@@ -338,30 +344,6 @@ class OpenIMSDK
|
|||||||
'void',
|
'void',
|
||||||
['baseCallback *', 'str', 'str']
|
['baseCallback *', 'str', 'str']
|
||||||
);
|
);
|
||||||
this.libOpenIMSDK.set_conversation_msg_destruct_time = this.lib.func(
|
|
||||||
'__stdcall',
|
|
||||||
'set_conversation_msg_destruct_time',
|
|
||||||
'void',
|
|
||||||
['baseCallback *', 'str', 'str', 'long long']
|
|
||||||
);
|
|
||||||
this.libOpenIMSDK.set_conversation_is_msg_destruct = this.lib.func(
|
|
||||||
'__stdcall',
|
|
||||||
'set_conversation_is_msg_destruct',
|
|
||||||
'void',
|
|
||||||
['baseCallback *', 'str', 'str', 'int']
|
|
||||||
);
|
|
||||||
this.libOpenIMSDK.send_group_message_read_receipt = this.lib.func(
|
|
||||||
'__stdcall',
|
|
||||||
'send_group_message_read_receipt',
|
|
||||||
'void',
|
|
||||||
['baseCallback *', 'str', 'str', 'str']
|
|
||||||
);
|
|
||||||
this.libOpenIMSDK.get_group_message_reader_list = this.lib.func(
|
|
||||||
'__stdcall',
|
|
||||||
'get_group_message_reader_list',
|
|
||||||
'void',
|
|
||||||
['baseCallback *', 'str', 'str', 'str', 'int', 'int', 'int']
|
|
||||||
);
|
|
||||||
this.libOpenIMSDK.hide_conversation = this.lib.func(
|
this.libOpenIMSDK.hide_conversation = this.lib.func(
|
||||||
'__stdcall',
|
'__stdcall',
|
||||||
'hide_conversation',
|
'hide_conversation',
|
||||||
@@ -847,6 +829,45 @@ class OpenIMSDK
|
|||||||
'int',
|
'int',
|
||||||
['baseCallback *', 'str', 'str']
|
['baseCallback *', 'str', 'str']
|
||||||
);
|
);
|
||||||
|
this.libOpenIMSDK.upload_file = this.lib.func(
|
||||||
|
'__stdcall',
|
||||||
|
'upload_file',
|
||||||
|
'void',
|
||||||
|
['baseCallback *', 'str', 'str', 'listenerCallback *']
|
||||||
|
);
|
||||||
|
|
||||||
|
// advance
|
||||||
|
if (this.enterprise) {
|
||||||
|
this.libOpenIMSDK.set_conversation_msg_destruct_time = this.lib.func(
|
||||||
|
'__stdcall',
|
||||||
|
'set_conversation_msg_destruct_time',
|
||||||
|
'void',
|
||||||
|
['baseCallback *', 'str', 'str', 'long long']
|
||||||
|
);
|
||||||
|
this.libOpenIMSDK.set_conversation_is_msg_destruct = this.lib.func(
|
||||||
|
'__stdcall',
|
||||||
|
'set_conversation_is_msg_destruct',
|
||||||
|
'void',
|
||||||
|
['baseCallback *', 'str', 'str', 'int']
|
||||||
|
);
|
||||||
|
this.libOpenIMSDK.send_group_message_read_receipt = this.lib.func(
|
||||||
|
'__stdcall',
|
||||||
|
'send_group_message_read_receipt',
|
||||||
|
'void',
|
||||||
|
['baseCallback *', 'str', 'str', 'str']
|
||||||
|
);
|
||||||
|
this.libOpenIMSDK.get_group_message_reader_list = this.lib.func(
|
||||||
|
'__stdcall',
|
||||||
|
'get_group_message_reader_list',
|
||||||
|
'void',
|
||||||
|
['baseCallback *', 'str', 'str', 'str', 'int', 'int', 'int']
|
||||||
|
);
|
||||||
|
this.libOpenIMSDK.set_signaling_listener = this.lib.func(
|
||||||
|
'__stdcall',
|
||||||
|
'set_signaling_listener',
|
||||||
|
'void',
|
||||||
|
['listenerCallback *']
|
||||||
|
);
|
||||||
this.libOpenIMSDK.signaling_invite_in_group = this.lib.func(
|
this.libOpenIMSDK.signaling_invite_in_group = this.lib.func(
|
||||||
'__stdcall',
|
'__stdcall',
|
||||||
'signaling_invite_in_group',
|
'signaling_invite_in_group',
|
||||||
@@ -958,21 +979,8 @@ class OpenIMSDK
|
|||||||
'void',
|
'void',
|
||||||
['baseCallback *', 'str', 'str', 'str']
|
['baseCallback *', 'str', 'str', 'str']
|
||||||
);
|
);
|
||||||
|
|
||||||
this.libOpenIMSDK.upload_file = this.lib.func(
|
|
||||||
'__stdcall',
|
|
||||||
'upload_file',
|
|
||||||
'void',
|
|
||||||
['baseCallback *', 'str', 'str', 'listenerCallback *']
|
|
||||||
);
|
|
||||||
|
|
||||||
Object.assign(this, setupUserModule(this));
|
|
||||||
Object.assign(this, setupFriendModule(this));
|
|
||||||
Object.assign(this, setupGroupModule(this));
|
|
||||||
Object.assign(this, setupConversationModule(this));
|
|
||||||
Object.assign(this, setupMessageModule(this));
|
|
||||||
Object.assign(this, setupSignalingModule(this));
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
generateEventResponse = (data: unknown, operationID = ''): BaseResponse => {
|
generateEventResponse = (data: unknown, operationID = ''): BaseResponse => {
|
||||||
let errCode = 0;
|
let errCode = 0;
|
||||||
@@ -1111,7 +1119,9 @@ class OpenIMSDK
|
|||||||
this.libOpenIMSDK.set_advanced_msg_listener(this.listenerCallback);
|
this.libOpenIMSDK.set_advanced_msg_listener(this.listenerCallback);
|
||||||
this.libOpenIMSDK.set_batch_msg_listener(this.listenerCallback);
|
this.libOpenIMSDK.set_batch_msg_listener(this.listenerCallback);
|
||||||
this.libOpenIMSDK.set_custom_business_listener(this.listenerCallback);
|
this.libOpenIMSDK.set_custom_business_listener(this.listenerCallback);
|
||||||
|
if (this.enterprise) {
|
||||||
this.libOpenIMSDK.set_signaling_listener(this.listenerCallback);
|
this.libOpenIMSDK.set_signaling_listener(this.listenerCallback);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
initSDK = (param: InitConfig, opid = uuidV4()) =>
|
initSDK = (param: InitConfig, opid = uuidV4()) =>
|
||||||
@@ -1275,16 +1285,16 @@ class OpenIMSDK
|
|||||||
createForwardMessage!: MessageModuleApi['createForwardMessage'];
|
createForwardMessage!: MessageModuleApi['createForwardMessage'];
|
||||||
createImageMessage!: MessageModuleApi['createImageMessage'];
|
createImageMessage!: MessageModuleApi['createImageMessage'];
|
||||||
createImageMessageFromFullPath!: MessageModuleApi['createImageMessageFromFullPath'];
|
createImageMessageFromFullPath!: MessageModuleApi['createImageMessageFromFullPath'];
|
||||||
createImageMessageByUrl!: MessageModuleApi['createImageMessageByUrl'];
|
createImageMessageByURL!: MessageModuleApi['createImageMessageByURL'];
|
||||||
createVideoMessage!: MessageModuleApi['createVideoMessage'];
|
createVideoMessage!: MessageModuleApi['createVideoMessage'];
|
||||||
createVideoMessageFromFullPath!: MessageModuleApi['createVideoMessageFromFullPath'];
|
createVideoMessageFromFullPath!: MessageModuleApi['createVideoMessageFromFullPath'];
|
||||||
createVideoMessageByUrl!: MessageModuleApi['createVideoMessageByUrl'];
|
createVideoMessageByURL!: MessageModuleApi['createVideoMessageByURL'];
|
||||||
createSoundMessage!: MessageModuleApi['createSoundMessage'];
|
createSoundMessage!: MessageModuleApi['createSoundMessage'];
|
||||||
createSoundMessageFromFullPath!: MessageModuleApi['createSoundMessageFromFullPath'];
|
createSoundMessageFromFullPath!: MessageModuleApi['createSoundMessageFromFullPath'];
|
||||||
createSoundMessageByUrl!: MessageModuleApi['createSoundMessageByUrl'];
|
createSoundMessageByURL!: MessageModuleApi['createSoundMessageByURL'];
|
||||||
createFileMessage!: MessageModuleApi['createFileMessage'];
|
createFileMessage!: MessageModuleApi['createFileMessage'];
|
||||||
createFileMessageFromFullPath!: MessageModuleApi['createFileMessageFromFullPath'];
|
createFileMessageFromFullPath!: MessageModuleApi['createFileMessageFromFullPath'];
|
||||||
createFileMessageByUrl!: MessageModuleApi['createFileMessageByUrl'];
|
createFileMessageByURL!: MessageModuleApi['createFileMessageByURL'];
|
||||||
getAdvancedHistoryMessageList!: MessageModuleApi['getAdvancedHistoryMessageList'];
|
getAdvancedHistoryMessageList!: MessageModuleApi['getAdvancedHistoryMessageList'];
|
||||||
getAdvancedHistoryMessageListReverse!: MessageModuleApi['getAdvancedHistoryMessageListReverse'];
|
getAdvancedHistoryMessageListReverse!: MessageModuleApi['getAdvancedHistoryMessageListReverse'];
|
||||||
sendMessage!: MessageModuleApi['sendMessage'];
|
sendMessage!: MessageModuleApi['sendMessage'];
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export function setupMessageModule(openIMSDK: OpenIMSDK) {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
createImageMessageByUrl: (params: ImageMsgParamsByURL, opid = uuidV4()) =>
|
createImageMessageByURL: (params: ImageMsgParamsByURL, opid = uuidV4()) =>
|
||||||
openIMSDK.asyncRetunWrap<MessageItem>(
|
openIMSDK.asyncRetunWrap<MessageItem>(
|
||||||
opid,
|
opid,
|
||||||
openIMSDK.libOpenIMSDK.create_image_message_by_url(
|
openIMSDK.libOpenIMSDK.create_image_message_by_url(
|
||||||
@@ -177,7 +177,7 @@ export function setupMessageModule(openIMSDK: OpenIMSDK) {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
createVideoMessageByUrl: (params: VideoMsgParamsByURL, opid = uuidV4()) =>
|
createVideoMessageByURL: (params: VideoMsgParamsByURL, opid = uuidV4()) =>
|
||||||
openIMSDK.asyncRetunWrap<MessageItem>(
|
openIMSDK.asyncRetunWrap<MessageItem>(
|
||||||
opid,
|
opid,
|
||||||
openIMSDK.libOpenIMSDK.create_video_message_by_url(
|
openIMSDK.libOpenIMSDK.create_video_message_by_url(
|
||||||
@@ -209,7 +209,7 @@ export function setupMessageModule(openIMSDK: OpenIMSDK) {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
createSoundMessageByUrl: (params: SoundMsgParamsByURL, opid = uuidV4()) =>
|
createSoundMessageByURL: (params: SoundMsgParamsByURL, opid = uuidV4()) =>
|
||||||
openIMSDK.asyncRetunWrap<MessageItem>(
|
openIMSDK.asyncRetunWrap<MessageItem>(
|
||||||
opid,
|
opid,
|
||||||
openIMSDK.libOpenIMSDK.create_sound_message_by_url(
|
openIMSDK.libOpenIMSDK.create_sound_message_by_url(
|
||||||
@@ -241,7 +241,7 @@ export function setupMessageModule(openIMSDK: OpenIMSDK) {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
createFileMessageByUrl: (params: FileMsgParamsByURL, opid = uuidV4()) =>
|
createFileMessageByURL: (params: FileMsgParamsByURL, opid = uuidV4()) =>
|
||||||
openIMSDK.asyncRetunWrap<MessageItem>(
|
openIMSDK.asyncRetunWrap<MessageItem>(
|
||||||
opid,
|
opid,
|
||||||
openIMSDK.libOpenIMSDK.create_file_message_by_url(
|
openIMSDK.libOpenIMSDK.create_file_message_by_url(
|
||||||
@@ -508,7 +508,7 @@ export interface MessageModuleApi {
|
|||||||
imagePath: string,
|
imagePath: string,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
createImageMessageByUrl: (
|
createImageMessageByURL: (
|
||||||
params: ImageMsgParamsByURL,
|
params: ImageMsgParamsByURL,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
@@ -520,7 +520,7 @@ export interface MessageModuleApi {
|
|||||||
params: VideoMsgByPathParams,
|
params: VideoMsgByPathParams,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
createVideoMessageByUrl: (
|
createVideoMessageByURL: (
|
||||||
params: VideoMsgParamsByURL,
|
params: VideoMsgParamsByURL,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
@@ -532,7 +532,7 @@ export interface MessageModuleApi {
|
|||||||
params: SoundMsgByPathParams,
|
params: SoundMsgByPathParams,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
createSoundMessageByUrl: (
|
createSoundMessageByURL: (
|
||||||
params: SoundMsgParamsByURL,
|
params: SoundMsgParamsByURL,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
@@ -544,7 +544,7 @@ export interface MessageModuleApi {
|
|||||||
params: FileMsgByPathParams,
|
params: FileMsgByPathParams,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
createFileMessageByUrl: (
|
createFileMessageByURL: (
|
||||||
params: FileMsgParamsByURL,
|
params: FileMsgParamsByURL,
|
||||||
opid?: string
|
opid?: string
|
||||||
) => Promise<BaseResponse<MessageItem>>;
|
) => Promise<BaseResponse<MessageItem>>;
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import OpenIMSDK from './core';
|
|||||||
class OpenIMSDKMain {
|
class OpenIMSDKMain {
|
||||||
private sdk: OpenIMSDK;
|
private sdk: OpenIMSDK;
|
||||||
private webContents: WebContents[] = [];
|
private webContents: WebContents[] = [];
|
||||||
constructor(path: string, webContent?: WebContents) {
|
constructor(path: string, webContent?: WebContents, enterprise = false) {
|
||||||
this.sdk = new OpenIMSDK(path, this.emitProxy);
|
this.sdk = new OpenIMSDK(path, this.emitProxy, enterprise);
|
||||||
if (webContent) {
|
if (webContent) {
|
||||||
this.webContents = [webContent];
|
this.webContents = [webContent];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user