This commit is contained in:
Your Name
2026-03-11 09:49:47 +08:00
parent 02ae537b4c
commit 38ad60f4bb
290 changed files with 36917 additions and 123 deletions
@@ -0,0 +1,47 @@
import { TUIBridge } from '../../../TUIBridge/index';
import { LOG_LEVEL } from '@trtc/call-engine-lite-wx';
import { COMPONENT, NAME, EVENT } from '../const/index';
export default class ChatCombine {
static instance: ChatCombine;
private _callService: any;
constructor(options) {
this._callService = options.callService;
TUIBridge.registerEvent(EVENT.LOGIN_SUCCESS, this);
TUIBridge.registerEvent(EVENT.LOGOUT_SUCCESS, this);
TUIBridge.registerEvent(EVENT.ON_CALLS, this);
}
static getInstance(options) {
if (!ChatCombine.instance) {
ChatCombine.instance = new ChatCombine(options);
}
return ChatCombine.instance;
}
/**
* tuicore notify event manager
* @param {String} eventName event name
* @param {String} subKey sub key
* @param {Any} options tuicore event parameters
*/
public async onNotifyEvent(options?: any) {
try {
if (options?.eventName === EVENT.LOGIN_SUCCESS) {
const { chat, userID, userSig, SDKAppID } = options?.params || {};
await this._callService?.init({ tim: chat, userID, userSig, sdkAppID: SDKAppID, isFromChat: true, component: COMPONENT.TIM_CALL_KIT });
this._callService?.setIsFromChat(true);
this._callService?.setLogLevel(LOG_LEVEL.NORMAL);
}
if (options?.eventName === EVENT.LOGOUT_SUCCESS) {
await this._callService?.destroyed();
}
if (options?.eventName === EVENT.ON_CALLS) {
options?.params && this._callService.calls(options.params);
}
} catch (error) {
console.error(`${NAME.PREFIX}TUICore onNotifyEvent failed, error: ${error}.`);
}
}
}