feat: method & types update (#9)

This commit is contained in:
blooming
2024-09-27 17:11:31 +08:00
committed by GitHub
parent 7e5fd0e082
commit 83ee57f324
21 changed files with 203 additions and 390 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

14
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@openim/electron-client-sdk",
"version": "1.0.9",
"version": "1.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@openim/electron-client-sdk",
"version": "1.0.9",
"version": "1.1.0",
"license": "MIT",
"dependencies": {
"koffi": "^2.8.0",
@@ -15,7 +15,7 @@
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@openim/wasm-client-sdk": "^3.8.0",
"@openim/wasm-client-sdk": "^3.8.2-beta.4",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-terser": "^0.4.4",
"@types/ffi-napi": "^4.0.10",
@@ -43,7 +43,7 @@
"node": ">=12.0"
},
"peerDependencies": {
"@openim/wasm-client-sdk": "^3.8.0",
"@openim/wasm-client-sdk": "^3.8.2-beta.3",
"electron": ">=12.0.0"
}
},
@@ -1882,9 +1882,9 @@
}
},
"node_modules/@openim/wasm-client-sdk": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/@openim/wasm-client-sdk/-/wasm-client-sdk-3.8.1.tgz",
"integrity": "sha512-1z90Z5A24MCeIuQtvP68GhQ2bEaS+XjpqtSnpLA9qcahaQqErzanzwJ4kDbo+1+Z0MFNqnDzjlnUjyf2FRv41Q==",
"version": "3.8.2-beta.4",
"resolved": "https://registry.npmjs.org/@openim/wasm-client-sdk/-/wasm-client-sdk-3.8.2-beta.4.tgz",
"integrity": "sha512-AH1FgOiQFM9bL1R18/z2oZkZwXKVZTy6EpMaBfSV6giM/++fwV4zLS0W/vJ7u8CrZgkcIPaY7h+JR3ICxn/3vg==",
"dev": true,
"engines": {
"node": ">=12.0"

View File

@@ -1,6 +1,6 @@
{
"name": "@openim/electron-client-sdk",
"version": "1.0.9",
"version": "1.1.0",
"description": "open im sdk for node",
"source": "src/index.ts",
"main": "lib/index.js",
@@ -43,9 +43,9 @@
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@openim/wasm-client-sdk": "^3.8.2-beta.4",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-terser": "^0.4.4",
"@openim/wasm-client-sdk": "^3.8.0",
"@types/ffi-napi": "^4.0.10",
"@types/node": "^12.20.55",
"@types/uuid": "^8.3.4",
@@ -80,7 +80,7 @@
"uuid": "^9.0.0"
},
"peerDependencies": {
"@openim/wasm-client-sdk": "^3.8.0",
"@openim/wasm-client-sdk": "^3.8.2-beta.3",
"electron": ">=12.0.0"
}
}

View File

@@ -24,6 +24,7 @@ import { CbEvents, LoginStatus, LogLevel } from '@openim/wasm-client-sdk';
import { SelfUserInfo } from '@openim/wasm-client-sdk/lib/types/entity';
import {
SetConversationExParams,
SetConversationParams,
SetFriendExParams,
UploadFileParams,
} from '@openim/wasm-client-sdk/lib/types/params';
@@ -364,47 +365,17 @@ class OpenIMSDK
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.get_conversation_recv_message_opt = this.lib.func(
'__stdcall',
'get_conversation_recv_message_opt',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.set_conversation_draft = this.lib.func(
'__stdcall',
'set_conversation_draft',
'void',
['baseCallback *', 'str', 'str', 'str']
);
this.libOpenIMSDK.reset_conversation_group_at_type = this.lib.func(
this.libOpenIMSDK.set_conversation = this.lib.func(
'__stdcall',
'reset_conversation_group_at_type',
'set_conversation',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.pin_conversation = this.lib.func(
'__stdcall',
'pin_conversation',
'void',
['baseCallback *', 'str', 'str', 'int']
);
this.libOpenIMSDK.set_conversation_private_chat = this.lib.func(
'__stdcall',
'set_conversation_private_chat',
'void',
['baseCallback *', 'str', 'str', 'int']
);
this.libOpenIMSDK.set_conversation_burn_duration = this.lib.func(
'__stdcall',
'set_conversation_burn_duration',
'void',
['baseCallback *', 'str', 'str', 'int']
);
this.libOpenIMSDK.set_conversation_recv_message_opt = this.lib.func(
'__stdcall',
'set_conversation_recv_message_opt',
'void',
['baseCallback *', 'str', 'str', 'int']
['baseCallback *', 'str', 'str', 'str']
);
this.libOpenIMSDK.get_total_unread_msg_count = this.lib.func(
'__stdcall',
@@ -544,11 +515,11 @@ class OpenIMSDK
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.get_users_info_with_cache = this.lib.func(
this.libOpenIMSDK.get_users_info = this.lib.func(
'__stdcall',
'get_users_info_with_cache',
'get_users_info',
'void',
['baseCallback *', 'str', 'str', 'str']
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.set_self_info = this.lib.func(
'__stdcall',
@@ -556,12 +527,6 @@ class OpenIMSDK
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.set_global_recv_message_opt = this.lib.func(
'__stdcall',
'set_global_recv_message_opt',
'void',
['baseCallback *', 'str', 'int']
);
this.libOpenIMSDK.get_self_user_info = this.lib.func(
'__stdcall',
'get_self_user_info',
@@ -593,23 +558,29 @@ class OpenIMSDK
['baseCallback *', 'str', 'str']
);
// Friend functions
this.libOpenIMSDK.get_specified_friends_info = this.lib.func(
this.libOpenIMSDK.update_friends = this.lib.func(
'__stdcall',
'get_specified_friends_info',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.get_specified_friends_info = this.lib.func(
'__stdcall',
'get_specified_friends_info',
'void',
['baseCallback *', 'str', 'str', 'int']
);
this.libOpenIMSDK.get_friend_list = this.lib.func(
'__stdcall',
'get_friend_list',
'void',
['baseCallback *', 'str']
['baseCallback *', 'str', 'int']
);
this.libOpenIMSDK.get_friend_list_page = this.lib.func(
'__stdcall',
'get_friend_list_page',
'void',
['baseCallback *', 'str', 'int', 'int']
['baseCallback *', 'str', 'int', 'int', 'int']
);
this.libOpenIMSDK.search_friends = this.lib.func(
'__stdcall',
@@ -629,12 +600,6 @@ class OpenIMSDK
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.set_friend_remark = this.lib.func(
'__stdcall',
'set_friend_remark',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.delete_friend = this.lib.func(
'__stdcall',
'delete_friend',
@@ -720,12 +685,6 @@ class OpenIMSDK
'void',
['baseCallback *', 'str', 'str', 'str', 'int']
);
this.libOpenIMSDK.set_group_member_role_level = this.lib.func(
'__stdcall',
'set_group_member_role_level',
'void',
['baseCallback *', 'str', 'str', 'str', 'int']
);
this.libOpenIMSDK.set_group_member_info = this.lib.func(
'__stdcall',
'set_group_member_info',
@@ -880,18 +839,6 @@ class OpenIMSDK
// 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',
@@ -973,48 +920,6 @@ class OpenIMSDK
['baseCallback *', 'str']
);
this.libOpenIMSDK.signaling_create_meeting = this.lib.func(
'__stdcall',
'signaling_create_meeting',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.signaling_join_meeting = this.lib.func(
'__stdcall',
'signaling_join_meeting',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.signaling_update_meeting_info = this.lib.func(
'__stdcall',
'signaling_update_meeting_info',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.signaling_close_room = this.lib.func(
'__stdcall',
'signaling_close_room',
'void',
['baseCallback *', 'str', 'str']
);
this.libOpenIMSDK.signaling_get_meetings = this.lib.func(
'__stdcall',
'signaling_get_meetings',
'void',
['baseCallback *', 'str']
);
this.libOpenIMSDK.signaling_operate_stream = this.lib.func(
'__stdcall',
'signaling_operate_stream',
'void',
['baseCallback *', 'str', 'str', 'str', 'str', 'int', 'int']
);
this.libOpenIMSDK.signaling_send_custom_signal = this.lib.func(
'__stdcall',
'signaling_send_custom_signal',
@@ -1350,7 +1255,7 @@ class OpenIMSDK
// implements user api
getSelfUserInfo!: UserModuleApi['getSelfUserInfo'];
setSelfInfo!: UserModuleApi['setSelfInfo'];
getUsersInfoWithCache!: UserModuleApi['getUsersInfoWithCache'];
getUsersInfo!: UserModuleApi['getUsersInfo'];
subscribeUsersStatus!: UserModuleApi['subscribeUsersStatus'];
unsubscribeUsersStatus!: UserModuleApi['unsubscribeUsersStatus'];
getSubscribeUsersStatus!: UserModuleApi['getSubscribeUsersStatus'];
@@ -1376,6 +1281,7 @@ class OpenIMSDK
removeBlack!: FriendModuleApi['removeBlack'];
searchFriends!: FriendModuleApi['searchFriends'];
setFriendRemark!: FriendModuleApi['setFriendRemark'];
updateFriends!: FriendModuleApi['updateFriends'];
// implements group api
createGroup!: GroupModuleApi['createGroup'];
@@ -1409,6 +1315,7 @@ class OpenIMSDK
getAllConversationList!: ConversationModuleApi['getAllConversationList'];
getConversationListSplit!: ConversationModuleApi['getConversationListSplit'];
getOneConversation!: ConversationModuleApi['getOneConversation'];
setConversation!: ConversationModuleApi['setConversation'];
setConversationEx!: (
params: SetConversationExParams,
opid?: string | undefined
@@ -1480,12 +1387,7 @@ class OpenIMSDK
signalingGetRoomByGroupID!: SignalingModuleApi['signalingGetRoomByGroupID'];
signalingGetTokenByRoomID!: SignalingModuleApi['signalingGetTokenByRoomID'];
signalingSendCustomSignal!: SignalingModuleApi['signalingSendCustomSignal'];
signalingCreateMeeting!: SignalingModuleApi['signalingCreateMeeting'];
signalingJoinMeeting!: SignalingModuleApi['signalingJoinMeeting'];
signalingUpdateMeetingInfo!: SignalingModuleApi['signalingUpdateMeetingInfo'];
signalingCloseRoom!: SignalingModuleApi['signalingCloseRoom'];
signalingGetMeetings!: SignalingModuleApi['signalingGetMeetings'];
signalingOperateStream!: SignalingModuleApi['signalingOperateStream'];
getSignalingInvitationInfoStartApp!: SignalingModuleApi['getSignalingInvitationInfoStartApp'];
}
export default OpenIMSDK;

View File

@@ -12,8 +12,10 @@ import {
SetConversationExParams,
SetConversationMsgDestructTimeParams,
SetConversationMsgDestructParams,
SetConversationParams,
} from '@openim/wasm-client-sdk/lib/types/params';
import { ConversationItem } from '@openim/wasm-client-sdk/lib/types/entity';
import { GroupAtType } from '@openim/wasm-client-sdk';
export function setupConversationModule(openIMSDK: OpenIMSDK) {
return {
@@ -47,11 +49,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
}),
setConversationEx: (params: SetConversationExParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_conversation_ex(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.ex
JSON.stringify({
ex: params.ex,
})
);
}),
getMultipleConversation: (conversationIDList: string, opid = uuidV4()) =>
@@ -101,13 +105,24 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
params.draftText
);
}),
pinConversation: (params: SetConversationPinParams, opid = uuidV4()) =>
setConversation: (params: SetConversationParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.pin_conversation(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.isPinned ? 1 : 0
JSON.stringify(params)
);
}),
pinConversation: (params: SetConversationPinParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
JSON.stringify({
isPinned: params.isPinned,
})
);
}),
setConversationRecvMessageOpt: (
@@ -115,11 +130,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_conversation_recv_message_opt(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.opt
JSON.stringify({
recvMsgOpt: params.opt,
})
);
}),
setConversationPrivateChat: (
@@ -127,11 +144,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_conversation_private_chat(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.isPrivate ? 1 : 0
JSON.stringify({
isPrivateChat: params.isPrivate,
})
);
}),
setConversationBurnDuration: (
@@ -139,19 +158,24 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_conversation_burn_duration(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.burnDuration
JSON.stringify({
burnDuration: params.burnDuration,
})
);
}),
resetConversationGroupAtType: (groupID: string, opid = uuidV4()) =>
resetConversationGroupAtType: (conversationID: string, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.reset_conversation_group_at_type(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
groupID
conversationID,
JSON.stringify({
groupAtType: GroupAtType.AtNormal,
})
);
}),
hideConversation: (conversationID: string, opid = uuidV4()) =>
@@ -196,11 +220,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_conversation_msg_destruct_time(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.msgDestructTime
JSON.stringify({
msgDestructTime: params.msgDestructTime,
})
);
}),
setConversationIsMsgDestruct: (
@@ -208,11 +234,11 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_conversation_is_msg_destruct(
openIMSDK.libOpenIMSDK.set_conversation(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.isMsgDestruct ? 1 : 0
JSON.stringify({ isMsgDestruct: params.isMsgDestruct })
);
}),
};
@@ -255,6 +281,10 @@ export interface ConversationModuleApi {
params: SplitConversationParams,
opid?: string
) => Promise<BaseResponse<void>>;
setConversation: (
params: SetConversationParams,
opid?: string
) => Promise<BaseResponse<void>>;
setConversationRecvMessageOpt: (
params: SetConversationRecvOptParams,
opid?: string
@@ -268,7 +298,7 @@ export interface ConversationModuleApi {
opid?: string
) => Promise<BaseResponse<void>>;
resetConversationGroupAtType: (
groupID: string,
conversationID: string,
opid?: string
) => Promise<BaseResponse<void>>;
hideConversation: (

View File

@@ -6,17 +6,20 @@ import {
AccessFriendApplicationParams,
AddBlackParams,
AddFriendParams,
GetSpecifiedFriendsParams,
OffsetParams,
PinFriendParams,
RemarkFriendParams,
SearchFriendParams,
SetFriendExParams,
UpdateFriendsParams,
} from '@openim/wasm-client-sdk/lib/types/params';
import {
FriendshipInfo,
BlackUserItem,
FriendApplicationItem,
FullUserItem,
SearchedFriendsInfo,
FriendUserItem,
} from '@openim/wasm-client-sdk/lib/types/entity';
export function setupFriendModule(openIMSDK: OpenIMSDK) {
@@ -72,11 +75,13 @@ export function setupFriendModule(openIMSDK: OpenIMSDK) {
setFriendsEx: (params: SetFriendExParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_friends_ex(
openIMSDK.libOpenIMSDK.update_friends(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
JSON.stringify(params),
params.ex ?? ''
JSON.stringify({
friendUserIDs: params.toUserIDs,
ex: params.ex,
})
);
}),
@@ -104,29 +109,47 @@ export function setupFriendModule(openIMSDK: OpenIMSDK) {
);
}),
getFriendList: (opid = uuidV4()) =>
new Promise<BaseResponse<FullUserItem[]>>((resolve, reject) => {
getFriendList: (filterBlack?: boolean, opid = uuidV4()) =>
new Promise<BaseResponse<FriendUserItem[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_friend_list(
openIMSDK.baseCallbackWrap<FullUserItem[]>(resolve, reject),
opid
openIMSDK.baseCallbackWrap<FriendUserItem[]>(resolve, reject),
opid,
filterBlack ? 1 : 0
);
}),
getFriendListPage: (params: OffsetParams, opid = uuidV4()) =>
new Promise<BaseResponse<FullUserItem[]>>((resolve, reject) => {
getFriendListPage: (
params: OffsetParams & { filterBlack?: boolean },
opid = uuidV4()
) =>
new Promise<BaseResponse<FriendUserItem[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_friend_list_page(
openIMSDK.baseCallbackWrap<FullUserItem[]>(resolve, reject),
openIMSDK.baseCallbackWrap<FriendUserItem[]>(resolve, reject),
opid,
params.offset,
params.count
params.count,
params.filterBlack ? 1 : 0
);
}),
getSpecifiedFriendsInfo: (userIDList: string[], opid = uuidV4()) =>
new Promise<BaseResponse<FullUserItem[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_specified_friends_info(
openIMSDK.baseCallbackWrap<FullUserItem[]>(resolve, reject),
updateFriends: (params: UpdateFriendsParams, opid = uuidV4()) =>
new Promise<BaseResponse<FriendUserItem[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.update_friends(
openIMSDK.baseCallbackWrap<FriendUserItem[]>(resolve, reject),
opid,
JSON.stringify(userIDList)
JSON.stringify(params)
);
}),
getSpecifiedFriendsInfo: (
params: GetSpecifiedFriendsParams,
opid = uuidV4()
) =>
new Promise<BaseResponse<FriendUserItem[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_specified_friends_info(
openIMSDK.baseCallbackWrap<FriendUserItem[]>(resolve, reject),
opid,
JSON.stringify(params.friendUserIDList),
params.filterBlack ? 1 : 0
);
}),
@@ -162,10 +185,25 @@ export function setupFriendModule(openIMSDK: OpenIMSDK) {
setFriendRemark: (params: RemarkFriendParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_friend_remark(
openIMSDK.libOpenIMSDK.update_friends(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
JSON.stringify(params)
JSON.stringify({
friendUserIDs: [params.toUserID],
remark: params.remark,
})
);
}),
pinFriends: (params: PinFriendParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.update_friends(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
JSON.stringify({
friendUserIDs: params.toUserIDs,
isPinned: params.isPinned,
})
);
}),
};
@@ -194,15 +232,22 @@ export interface FriendModuleApi {
getFriendApplicationListAsRecipient: (
opid?: string
) => Promise<BaseResponse<FriendApplicationItem[]>>;
getFriendList: (opid?: string) => Promise<BaseResponse<FullUserItem[]>>;
getFriendList: (
filterBlack?: boolean,
opid?: string
) => Promise<BaseResponse<FriendUserItem[]>>;
getFriendListPage: (
params: OffsetParams,
params: OffsetParams & { filterBlack?: boolean },
opid?: string
) => Promise<BaseResponse<FullUserItem[]>>;
) => Promise<BaseResponse<FriendUserItem[]>>;
updateFriends: (
params: UpdateFriendsParams,
opid?: string
) => Promise<BaseResponse<void>>;
getSpecifiedFriendsInfo: (
userIDList: string[],
params: GetSpecifiedFriendsParams,
opid?: string
) => Promise<BaseResponse<FullUserItem[]>>;
) => Promise<BaseResponse<FriendUserItem[]>>;
refuseFriendApplication: (
params: AccessFriendApplicationParams,
opid?: string

View File

@@ -2,17 +2,13 @@ import { v4 as uuidV4 } from 'uuid';
import OpenIMSDK from '..';
import { BaseResponse } from '@/types/entity';
import {
CreateMeetingParams,
CustomSignalParams,
MeetingOperateStreamParams,
RtcActionParams,
SignalingInviteParams,
UpdateMeetingParams,
} from '@openim/wasm-client-sdk/lib/types/params';
import {
RtcInviteResults,
CallingRoomData,
MeetingRecord,
} from '@openim/wasm-client-sdk/lib/types/entity';
export function setupSignalingModule(openIMSDK: OpenIMSDK) {
@@ -81,6 +77,13 @@ export function setupSignalingModule(openIMSDK: OpenIMSDK) {
roomID
);
}),
getSignalingInvitationInfoStartApp: (opid = uuidV4()) =>
new Promise<BaseResponse<RtcInviteResults>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_signaling_invitation_info_start_app(
openIMSDK.baseCallbackWrap<RtcInviteResults>(resolve, reject),
opid
);
}),
signalingSendCustomSignal: (params: CustomSignalParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.signaling_send_custom_signal(
@@ -90,70 +93,6 @@ export function setupSignalingModule(openIMSDK: OpenIMSDK) {
params.roomID
);
}),
signalingCreateMeeting: (params: CreateMeetingParams, opid = uuidV4()) =>
new Promise<BaseResponse<RtcInviteResults>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.signaling_create_meeting(
openIMSDK.baseCallbackWrap<RtcInviteResults>(resolve, reject),
opid,
JSON.stringify(params)
);
}),
signalingJoinMeeting: (roomID: string, opid = uuidV4()) =>
new Promise<BaseResponse<RtcInviteResults>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.signaling_join_meeting(
openIMSDK.baseCallbackWrap<RtcInviteResults>(resolve, reject),
opid,
JSON.stringify({
roomID,
})
);
}),
signalingUpdateMeetingInfo: (
params: Partial<UpdateMeetingParams> & { roomID: string },
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.signaling_update_meeting_info(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
JSON.stringify(params)
);
}),
signalingCloseRoom: (roomID: string, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.signaling_close_room(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
roomID
);
}),
signalingGetMeetings: (opid = uuidV4()) =>
new Promise<BaseResponse<{ meetingInfoList: MeetingRecord[] }>>(
(resolve, reject) => {
openIMSDK.libOpenIMSDK.signaling_get_meetings(
openIMSDK.baseCallbackWrap<{ meetingInfoList: MeetingRecord[] }>(
resolve,
reject
),
opid
);
}
),
signalingOperateStream: (
params: MeetingOperateStreamParams,
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.signaling_operate_stream(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.streamType,
params.roomID,
params.userID ?? '',
params.mute ? 1 : 0,
params.muteAll ? 1 : 0
);
}),
};
}
@@ -190,31 +129,11 @@ export interface SignalingModuleApi {
roomID: string,
opid?: string
) => Promise<BaseResponse<RtcInviteResults>>;
getSignalingInvitationInfoStartApp: (
opid?: string
) => Promise<BaseResponse<RtcInviteResults>>;
signalingSendCustomSignal: (
params: CustomSignalParams,
opid?: string
) => Promise<BaseResponse<void>>;
signalingCreateMeeting: (
params: CreateMeetingParams,
opid?: string
) => Promise<BaseResponse<RtcInviteResults>>;
signalingJoinMeeting: (
meetingID: string,
opid?: string
) => Promise<BaseResponse<RtcInviteResults>>;
signalingUpdateMeetingInfo: (
params: Partial<UpdateMeetingParams> & { roomID: string },
opid?: string
) => Promise<BaseResponse<void>>;
signalingCloseRoom: (
roomID: string,
opid?: string
) => Promise<BaseResponse<void>>;
signalingGetMeetings: (
opid?: string
) => Promise<BaseResponse<{ meetingInfoList: MeetingRecord[] }>>;
signalingOperateStream: (
params: MeetingOperateStreamParams,
opid?: string
) => Promise<BaseResponse<void>>;
}

View File

@@ -4,13 +4,10 @@ import OpenIMSDK from '..';
import { MessageReceiveOptType } from '@openim/wasm-client-sdk';
import {
SelfUserInfo,
FullUserItemWithCache,
UserOnlineState,
PublicUserItem,
} from '@openim/wasm-client-sdk/lib/types/entity';
import {
GetUserInfoWithCacheParams,
PartialUserItem,
} from '@openim/wasm-client-sdk/lib/types/params';
import { PartialUserItem } from '@openim/wasm-client-sdk/lib/types/params';
export function setupUserModule(openIMSDK: OpenIMSDK) {
return {
@@ -31,16 +28,12 @@ export function setupUserModule(openIMSDK: OpenIMSDK) {
);
}),
getUsersInfoWithCache: (
params: GetUserInfoWithCacheParams,
opid = uuidV4()
) =>
new Promise<BaseResponse<FullUserItemWithCache[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_users_info_with_cache(
openIMSDK.baseCallbackWrap<FullUserItemWithCache[]>(resolve, reject),
getUsersInfo: (params: string[], opid = uuidV4()) =>
new Promise<BaseResponse<PublicUserItem[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_users_info(
openIMSDK.baseCallbackWrap<PublicUserItem[]>(resolve, reject),
opid,
JSON.stringify(params.userIDList),
params.groupID ?? ''
JSON.stringify(params)
);
}),
@@ -75,10 +68,12 @@ export function setupUserModule(openIMSDK: OpenIMSDK) {
opid = uuidV4()
) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.set_global_recv_message_opt(
openIMSDK.libOpenIMSDK.set_self_info(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
msgReceiveOptType
JSON.stringify({
globalRecvMsgOpt: msgReceiveOptType,
})
);
}),
};
@@ -90,10 +85,10 @@ export interface UserModuleApi {
params: PartialUserItem,
opid?: string
) => Promise<BaseResponse<void>>;
getUsersInfoWithCache: (
params: GetUserInfoWithCacheParams,
getUsersInfo: (
params: string[],
opid?: string
) => Promise<BaseResponse<FullUserItemWithCache[]>>;
) => Promise<BaseResponse<PublicUserItem[]>>;
subscribeUsersStatus: (
userIDList: string[],
opid?: string

View File

@@ -1,4 +1,4 @@
import { ipcMain, WebContents } from 'electron';
import { ipcMain, powerMonitor, WebContents } from 'electron';
import { CbEvents } from '@openim/wasm-client-sdk';
import OpenIMSDK from './core';
@@ -10,9 +10,19 @@ class OpenIMSDKMain {
if (webContent) {
this.webContents = [webContent];
}
this.systemStateHandler();
this.initMethodsHandler();
}
private systemStateHandler = () => {
powerMonitor.on('suspend', () => {
this.sdk.setAppBackgroundStatus(true);
});
powerMonitor.on('resume', () => {
this.sdk.setAppBackgroundStatus(false);
});
};
private initMethodsHandler = () => {
ipcMain.handle('openim-sdk-ipc-methods', async (_, method, ...args) => {
try {

View File

@@ -1,5 +1,11 @@
import { contextBridge, ipcRenderer } from 'electron';
const updateOnlineStatus = () =>
ipcRenderer.invoke('openim-sdk-ipc-methods', 'networkStatusChanged');
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
contextBridge.exposeInMainWorld('openIMRenderApi', {
subscribe: (channel: string, callback: (...args: any[]) => void) => {
const subscription = (_: unknown, ...args: any[]) => callback(...args);

View File

@@ -158,18 +158,6 @@ declare module 'libOpenIMSDK' {
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;
send_group_message_read_receipt(
cCallback: CB_S_I_S_S,
operationID: string,
@@ -190,57 +178,23 @@ declare module 'libOpenIMSDK' {
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(
set_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
conversationFields: string
): void;
get_total_unread_msg_count(
cCallback: CB_S_I_S_S,
operationID: string
): void;
get_at_all_tag(operationID: string): string;
set_conversation_ex(
cCallback: CB_S_I_S_S,
operationID: string,
conversationID: string,
ex: string
): void;
get_conversation_id_by_session_type(
operationID: string,
sourceID: string,
@@ -355,13 +309,7 @@ declare module 'libOpenIMSDK' {
operationID: 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(
get_users_info(
cCallback: CB_S_I_S_S,
operationID: string,
userIDs: string
@@ -371,11 +319,6 @@ declare module 'libOpenIMSDK' {
operationID: string,
userInfo: string
): 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;
update_msg_sender_info(
cCallback: CB_S_I_S_S,
@@ -406,26 +349,26 @@ declare module 'libOpenIMSDK' {
get_specified_friends_info(
cCallback: CB_S_I_S_S,
operationID: string,
userIDList: string
userIDList: string,
filterBlack?: number
): void;
get_friend_list(
cCallback: CB_S_I_S_S,
operationID: string,
filterBlack?: number
): void;
get_friend_list(cCallback: CB_S_I_S_S, operationID: string): void;
get_friend_list_page(
cCallback: CB_S_I_S_S,
operationID: string,
offset: number,
count: number
count: number,
filterBlack?: number
): void;
search_friends(
cCallback: CB_S_I_S_S,
operationID: string,
searchParam: string
): void;
set_friends_ex(
cCallback: CB_S_I_S_S,
operationID: string,
toUserIDs: string,
ex: string
): void;
check_friend(
cCallback: CB_S_I_S_S,
operationID: string,
@@ -436,10 +379,10 @@ declare module 'libOpenIMSDK' {
operationID: string,
userIDReqMsg: string
): void;
set_friend_remark(
update_friends(
cCallback: CB_S_I_S_S,
operationID: string,
userIDRemark: string
friendInfos: string
): void;
delete_friend(
cCallback: CB_S_I_S_S,
@@ -513,13 +456,6 @@ declare module 'libOpenIMSDK' {
cUserID: string,
cMutedSeconds: number
): void;
set_group_member_role_level(
cCallback: CB_S_I_S_S,
operationID: string,
cGroupID: string,
cUserID: string,
cRoleLevel: number
): void;
set_group_member_info(
cCallback: CB_S_I_S_S,
operationID: string,
@@ -703,36 +639,6 @@ declare module 'libOpenIMSDK' {
cCallback: CB_S_I_S_S,
operationID: string
): void;
signaling_create_meeting(
cCallback: CB_S_I_S_S,
operationID: string,
cSignalingCreateMeetingReq: string
): void;
signaling_join_meeting(
cCallback: CB_S_I_S_S,
operationID: string,
cSignalingJoinMeetingReq: string
): void;
signaling_update_meeting_info(
cCallback: CB_S_I_S_S,
operationID: string,
cSignalingUpdateMeetingInfoReq: string
): void;
signaling_close_room(
cCallback: CB_S_I_S_S,
operationID: string,
cRoomID: string
): void;
signaling_get_meetings(cCallback: CB_S_I_S_S, operationID: string): void;
signaling_operate_stream(
cCallback: CB_S_I_S_S,
operationID: string,
cStreamType: string,
cRoomID: string,
cUserID: string,
mute: number,
muteAll: number
): void;
signaling_send_custom_signal(
cCallback: CB_S_I_S_S,
operationID: string,