@rongcloud/electron 5.3.0 → 5.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +5 -2
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -398,7 +398,7 @@ interface ICppProtocol {
|
|
|
398
398
|
/**
|
|
399
399
|
* 加入 RTC 房间
|
|
400
400
|
*/
|
|
401
|
-
joinRTCRoom: (roomId: string, roomType: number, liveType: number, joinType: RTCJoinType, onSuccess: (result: string, token: string, sessionId: string, roomInfo: string) => void, onError: IOnErrorCallBack, key?: string, value?: string, inner?: string, outer?: string) => void;
|
|
401
|
+
joinRTCRoom: (roomId: string, roomType: number, liveType: number, joinType: RTCJoinType, onSuccess: (result: string, token: string, sessionId: string, roomInfo: string, kvEntries: [], offlineKickTime: number) => void, onError: IOnErrorCallBack, key?: string, value?: string, inner?: string, outer?: string) => void;
|
|
402
402
|
/**
|
|
403
403
|
* 退出 RTC 房间
|
|
404
404
|
*/
|
|
@@ -487,7 +487,7 @@ interface ICppProtocol {
|
|
|
487
487
|
/**
|
|
488
488
|
* TODO 主播切观众仅返回 token 待验证
|
|
489
489
|
*/
|
|
490
|
-
onSuccess: (result: string, token: string, sessionId: string, roomInfo: string, entries: string) => void, onError: IOnErrorCallBack) => void;
|
|
490
|
+
onSuccess: (result: string, token: string, sessionId: string, roomInfo: string, entries: string, offlineKickTime: number) => void, onError: IOnErrorCallBack) => void;
|
|
491
491
|
/**
|
|
492
492
|
* 观众房间,资源通知监听
|
|
493
493
|
*/
|
|
@@ -580,6 +580,7 @@ declare class RCCppService implements IEngine, IExtraMethod {
|
|
|
580
580
|
private _initOptions;
|
|
581
581
|
private _naviInfo;
|
|
582
582
|
private _version;
|
|
583
|
+
private naviInfo;
|
|
583
584
|
constructor(_cppProtocol: ICppProtocol, _dbpath?: string, _reconnectKickEnable?: boolean);
|
|
584
585
|
private _callCppProxy;
|
|
585
586
|
/**
|
|
@@ -602,6 +603,7 @@ declare class RCCppService implements IEngine, IExtraMethod {
|
|
|
602
603
|
hasMore: boolean;
|
|
603
604
|
}>>;
|
|
604
605
|
updateMessageReceiptStatus(conversationType: ConversationType, targetId: string, timestamp: number, channelId?: string): Promise<IAsyncRes<boolean>>;
|
|
606
|
+
requestNaviInfo(uris: string[], appkey: string, token: string, checkCA?: boolean): Promise<INaviInfo | null>;
|
|
605
607
|
getConnectedTime(): number;
|
|
606
608
|
getServerTime(): number;
|
|
607
609
|
getCurrentUserId(): string;
|
|
@@ -627,6 +629,7 @@ declare class RCCppService implements IEngine, IExtraMethod {
|
|
|
627
629
|
* 返回列表数据的格式转换
|
|
628
630
|
*/
|
|
629
631
|
private _convertResultList;
|
|
632
|
+
private _connectResolve;
|
|
630
633
|
/**
|
|
631
634
|
* 设置连接状态监听器
|
|
632
635
|
* ConnectionStatus_TokenIncorrect = 31004,
|
package/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{platform as e,arch as t}from"os";import{resolve as o}from"path";import{Logger as n,ConnectionStatus as r,LogLevel as i,ErrorCode as s,ConversationType as a,SEND_MESSAGE_TYPE_OPTION as c,isObject as u,isUndefined as p,pushJSONToConfigs as l,MessageDirection as d,NotificationStatus as f,MessageType as C,pushConfigsToJSON as g,MentionedType as h,ReceivedStatus as v,isArray as _,getUploadFileName as S,RTCJoinType as y,RTCApiType as m,LiveType as P}from"@rongcloud/engine";import{ipcMain as E,app as R}from"electron";import{existsSync as T,readFileSync as I,writeFileSync as N}from"fs";import{createHash as O}from"crypto";var U=process.versions.electron.replace(/\.\d+$/,""),M=o(__dirname,"binding","electron-v".concat(U,"-").concat(e(),"-").concat(t(),".node")),x=null;try{x=require(M)}catch(e){console.error("error ->",M,"\n",e)}var b=x,w=function(){return w=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},w.apply(this,arguments)};function L(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function D(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function A(e,t,o){if(o||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}var J,k=new n("RCMain"),H=null,F=function(){var o,n=Date.now(),r=[t(),e(),process.pid,n,Math.floor(Math.random()*n)].join("__");return o=r,O("md5").update(o).digest("hex")},j=function(e){if(H)return H;var t=o(e,"deviceId");return k.debug("deviceIdPath -> ".concat(t)),T(t)?H=I(t).toString():(H=F(),k.debug("createDeviceId -> ".concat(H)),N(t,H),H)},B=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,o){return J?(J.stop(),J):J=new e(t,o)},e.prototype.start=function(e){var t=this,o=this,n=function(){var r=t._isFirstPing?0:15e3;o._timerId=setTimeout((function(){o._isFirstPing=!1,k.debug("current lossCount: "+o._lossCount),o._hasPingRes?(e(),o._hasPingRes=!1,n()):o._lossCount<4?(o._lossCount++,e(),n()):o._reconnect()}),r)};n()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){k.debug("receive pong"),this._hasPingRes=e,this._lossCount=0},e}(),K=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,o,n,r){var i=JSON.stringify(n);k.info("MsgExpansion._setToProtocol ===>",e,t,o,i,r),this._cppProto.setMessageExtension(e,t,o,i,r)},e.prototype.setLocalFromReceiveMsg=function(e){k.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId,r=e.messageUId,i=e.expansion,s=e.sentTime,a={};for(var c in i)a[c]={v:"",ts:0},a[c].v=i[c],a[c].ts=s;this._setToProtocol(o,n,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){k.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId;e.messageUId;var r=e.content,i=e.sentTime,s=r,a=s.put,c=this._cppProto.getMessage(s.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(k.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var l in a){var d=p[l];d&&d.ts<i-this._setTime?(d.v=a[l],d.ts=i-this._setTime):(p[l]={v:"",ts:0},p[l].v=a[l],p[l].ts=i-this._setTime)}s.del&&s.del.forEach((function(e){delete p[e]})),this._setToProtocol(o,n,s.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}(),V=function(e){var t=[];return JSON.parse(e).list.forEach((function(e){t.push(JSON.parse(e.obj))})),t},W=function(e){return JSON.parse(e).list.map((function(e){return{key:Object.keys(e)[0],value:Object.values(e)[0]}}))},q=function(){function e(e,t,o){void 0===t&&(t=""),void 0===o&&(o=!1);var n=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=o,this._currentToken="",this._connectionStatus=r.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=r.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._version="5.3.0",this._logger={debug:this._superLog.bind(this,"debug",i.DEBUG),info:this._superLog.bind(this,"info",i.INFO),warn:this._superLog.bind(this,"warn",i.WARN),error:this._superLog.bind(this,"error",i.ERROR),fatal:this._superLog.bind(this,"fatal",i.FATAL)},this._senders={},E.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];return L(n,void 0,void 0,(function(){var n,r,i,a;return D(this,(function(c){switch(c.label){case 0:if((a=this._logger).debug.apply(a,A(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],o,!1)),"function"!=typeof(n=this[t]))return e.returnValue=s.NOT_SUPPORT,[2];r=s.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,n.call.apply(n,A([this],o,!1))];case 2:return r=c.sent(),[3,4];case 3:return i=c.sent(),this._logger.error("call main process method `".concat(t,"` failed.")),this._logger.error(i),[3,4];case 4:return e.returnValue=r,[2]}}))}))})),E.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,o){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return L(n,void 0,void 0,(function(){var n,i,a,c,u,p=this;return D(this,(function(l){switch(l.label){case 0:if((u=this._logger).debug.apply(u,A(["__RC_CHANNEL_CALL_MAIN__",t,o],r,!1)),"function"!=typeof(n=this[o]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,s.NOT_SUPPORT),[2];"sendMessage"===o&&(i=r.pop(),r.push((function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",i,t)}))),a=s.EXTRA_METHOD_UNDEFINED,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,n.call.apply(n,A([this],r,!1))];case 2:return a=l.sent(),[3,4];case 3:return c=l.sent(),this._logger.error("call main process method `".concat(o,"` failed.")),this._logger.error(c),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),E.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];(o=n._logger).debug.apply(o,A(["__RC_CHANNEL_CALL_MAIN__",t],r,!1));var s=n[t];if("function"==typeof s)try{s.call.apply(s,A([n],r,!1))}catch(e){n._logger.error("call main process method `".concat(t,"` failed.")),n._logger.error(e)}else n._logger.error("cannot not found method: ".concat(t))})),E.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new K(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,o,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,n)}catch(t){(o=this._logger).error.apply(o,A([t,e],n,!1))}},e.prototype._superLog=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];if(k[e]&&k[e].apply(k,o),t!==i.DEBUG){var r=Object.keys(this._senders);if(r.length>0){var s=o.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[r[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,s,"RCMain")}}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];(t=this._logger).info.apply(t,A(["callExtra -> ".concat(e)],o,!1));var r=this[e];if(!r)return this._logger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:s.EXTRA_METHOD_UNDEFINED});try{return r.call.apply(r,A([this],o,!1))}catch(e){this._logger.error(e)}return Promise.resolve({code:s.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,o,n){var r,i=this,a=this._callCppProxy("getConversationListByPage",e,t,o,n||"");try{r=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:r})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,o=[a.PRIVATE,a.GROUP],n=this._callCppProxy("getConversationListWithAllChannel",o);try{e=JSON.parse(n).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var o,n=this,r=[a.PRIVATE,a.GROUP],i=this._callCppProxy("getConversationListWithAllChannelByPage",r,e,t);try{o=JSON.parse(i).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:o})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,o,n,r,i,a){var c=0===i,u=n+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,o,u,r,c,a||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var f=0;f<d.length;f++){var C=this._buildMessage(d[f].obj);l[f]=C}}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:n<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,o,n){void 0===n&&(n=""),this._logger.info("updateMessageReceiptStatus ->",e,t,o,n);var r=this._callCppProxy("updateMessageReceiptStatus",e,t,o,n);return Promise.resolve({code:s.SUCCESS,data:r})},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this._naviInfo.userId},e.prototype._send2Renderer=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,A([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var n=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(r){var i=n._senders[r];o.includes(i)||n._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,t){var n=this,r=e.sender,i=r.id;if(this._senders[i]||(this._senders[i]=r,r.once("destroyed",(function(){delete n._senders[i]}))),!this._inited){this._inited=!0,this._initOptions=t,this._logger.info("init ->",t);var s=this._dbpath||o(R.getPath("userData"));this._callCppProxy("initWithAppkey",t.appkey,s),this._logger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var a=j(s);this._logger.info("deviceId -> ".concat(a)),this._callCppProxy("setDeviceId",a),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in c["RC:RcCmd"]={isCounted:!1,isPersited:!1},c){var t=c[e],o=t.isCounted,n=0;t.isPersited&&(n|=1),o&&(n|=2),"RC:TypSts"===e&&(n=16),this._logger.info("_registerMsgTypes ====>",e,n),this._callCppProxy("registerMessageType",e,n)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var o=t.isOffLineMessage,n=t.buildFrom,r=JSON.parse(e);this._logger.debug("_buildMessage:",r);var i=r.channelId,s=r.conversationType,a=r.targetId,f=r.senderUserId,C=r.content,g=r.objectName,h=r.messageUid,v=r.direction,_=r.status;r.source;var S=r.messageId,y=r.sentTime,m=r.readReceiptRequest,P=r.supportExt;r.extMsg;var E,R=r.pushContent,T=r.pushTitle,I=r.pushId,N=r.pushConfig,O=r.templateId,U=r.disableTitle,M=r.forcePushDetail;if(u(C))E=C;else try{E=C?JSON.parse(C):C}catch(e){k.warn("cpp engine build messaga error:",e),E=C}var x={isCounted:!1,isPersited:!1};g in c?x=c[g]:g in this._customMessageType&&(x=this._customMessageType[g]);var b=null;P&&(b=this._msgExpansionHandler.parseReceiveExpansion(r),"conversation"!==n&&"history"!==n||(b=this._msgExpansionHandler.parseConverOrHisExpansion(r)));var L=p(o)?y<this._connectedTime:o,D={};N&&(D=l(N,I));var A=w(w({},D),{pushTitle:T,pushContent:R,pushData:R,disablePushTitle:U,forceShowDetailContent:M,templateId:O}),J={channelId:i,conversationType:s,targetId:a,senderUserId:f,content:E||{},messageType:g,messageUId:h,messageDirection:v,isOffLineMessage:L,sentTime:y,receivedTime:0,isPersited:x.isPersited,isCounted:x.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:P,expansion:P?b:null,receivedStatus:_,messageId:S,pushConfig:A};if(v===d.RECEIVE?J.receivedStatus=_:v===d.SEND&&(J.sentStatus=_),m){var H=JSON.parse(m),F=H.hasRespond,j=H.readerInfo,B={hasRespond:F,readCount:H.readCount,totalCount:H.totalCount},K=[];if(j)for(var V in j)K.push({userId:V,readTime:j[V]});B.readerList=K,J.readReceiptInfo=B}return J},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},i=w(w({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._logger.debug("_buildConversation",t);var o=t.channelId,n=t.conversationType,r=t.targetId,i=t.unreadCount,s=t.lastestMsg,a=t.isTop,c=t.isBlocked,u=t.matchCount,p=c?f.OPEN:f.CLOSE;return{channelId:o,conversationType:n,targetId:r,unreadMessageCount:i,latestMessage:-1===JSON.parse(s).messageId?null:this._buildMessage(s),hasMentioned:!1,mentionedInfo:null,notificationStatus:p,isTop:a,lastUnreadTime:0,matchCount:u}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var o;switch(e._logger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:o=r.CONNECTING;break;case 31004:return void setTimeout((function(){e._promiseHandler.connect&&e._promiseHandler.connect.resolve(s.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:o=r.DISCONNECTED;break;case 13:o=r.BLOCKED;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:o=r.NETWORK_UNAVAILABLE;break;case 30010:o=r.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===r.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:o=r.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._promiseHandler.connect&&e._promiseHandler.connect.resolve(s.SUCCESS),e._heartbeat=B.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case r.KICKED_OFFLINE_BY_OTHER_CLIENT:o=r.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:o=r.REDIRECT;break;default:o=t}o!==r.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=o,e._sendConnectionStatus2Renderer(o)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;k.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(r.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){k.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){k.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,o,n,r){var i=e._buildMessage(t,{isOffLineMessage:n});if(i.messageType===C.GROUP_READ_RECEIPT_REQUEST){var s=i.content,a=s.msgId,c=s.rrn,u=s.tmn;e._updateReadReceiptInfo(a,{readCount:c,totalCount:u})}if("RC:MsgExMsg"===i.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(i),void e._sendMessageExpansion(i);if(i.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(i),i.messageType===C.SYNC_READ_STATUS){if(i.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,i.channelId||"")}var p=!0;if(0!==o||r||(p=!1),i.messageType!==C.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){var l=i.conversationType,d=i.targetId;i.messageType===C.RECALL&&i.senderUserId===e._currentUserId&&(l=i.content.conversationType||l,d=i.content.targetId||d),e._sendMessageNotification(Object.assign(i,{hasMoreMsg:p,conversationType:l,targetId:d}))}else{var f=Object.keys(e._senders).map((function(t){return e._senders[t]}));f.length>0&&e._sendMessageNotification(Object.assign(i,{hasMoreMsg:p}),f.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,n=e.content,r=n.put,i=n.del,s=n.mid,a={};r&&(a.updatedExpansion={channelId:o,messageUId:s,expansion:r}),i&&(a.deletedExpansion={channelId:o,messageUId:s,deletedKeys:i}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var o=JSON.parse(t).list,n=[];o.forEach((function(e){var t=JSON.parse(e.obj),o=t.conversationType,r=t.targetId,i=t.status,s=t.channelId,a={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?a.notificationStatus=1===Number(t.value)?f.OPEN:f.CLOSE:a.isTop=1===Number(t.value)})),n.push({channelId:s,conversationType:o,targetId:r,updatedItems:{notificationStatus:{val:a.notificationStatus,time:0},isTop:{val:a.isTop,time:0}}})})),e._send2AllRenderer("conversation",n)}),(function(t){e._logger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._logger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){k.info("RTC Room Data Change:",t);var o=JSON.parse(t).list.map((function(e){var t=JSON.parse(e.obj);return{key:t.key,value:t.value,uid:t.operator,timestamp:t.version,status:t.isDeleted?1:0,roomId:t.roomId||""}}));e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,o,n){var r=0;t&&(r|=1),o&&(r|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this._callCppProxy("registerMessageType",e,r,n)},e.prototype.connect=function(e,t,o){var n=this;return this._logger.info("connect ->",e,t,o),this._currentToken===e&&this._connectionStatus===r.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(s.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,this._doConnect(o),new Promise((function(e,t){n._promiseHandler.connect={resolve:e,reject:t}})))},e.prototype._doConnect=function(e){var t=p(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._logger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop()},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("subscribeUserStatus",e,(function(){o(s.SUCCESS)}),o)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("setUserStatus",e,(function(){o(s.SUCCESS)}),o)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("getUserStatus",e,(function(e){o({code:s.SUCCESS,data:{status:e}})}),(function(e){o({code:e})}))}))},e.prototype.sendMessage=function(e,t,o,n){var r=this,i=o.messageType,c=o.content,u=o.pushContent,p=o.pushData,l=o.directionalUserIdList,d=o.disableNotification,f=o.canIncludeExpansion,v=o.expansion,_=o.isVoipPush,S=o.pushConfig,y=o.channelId,m=o.isMentioned,P=o.mentionedType,E=o.mentionedUserIdList,R=S||{},T=R.iOSConfig,I=R.androidConfig,N=R.pushTitle,O=R.pushContent,U=R.pushData,M=R.disablePushTitle,x=R.forceShowDetailContent,b=R.templateId,w=g(T,I);return new Promise((function(o){u=O||u||"",p=U||p||"",d=d||!1,_=_||!1,N=N||"",O=O||"",U=U||"",M=M||!1,x=x||!1,f=f||!1;var g=(null==I?void 0:I.notificationId)||"";if(l=l||[],y=y||"",e===a.GROUP&&m&&c&&(c.mentionedInfo={userIdList:E,type:P||h.ALL}),e===a.GROUP&&i===C.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var S in c.receiptMessageDic)l.push(S);var R={};for(var S in v)R[S]={v:""},R[S].v=v[S];var T=b||"",L=r._callCppProxy("sendMessage",(function(e,t){var n=r._buildMessage(e,{isOffLineMessage:!1});return t===s.SENSITIVE_REPLACE?o({code:t}):("RC:MsgExMsg"===n.messageType&&r._msgExpansionHandler.setLocalFromExtMsg(n),n.canIncludeExpansion&&r._msgExpansionHandler.setLocalFromReceiveMsg(n),o({code:s.SUCCESS,data:n}))}),(function(e,t){var n=r._buildMessage(e,{isOffLineMessage:!1});return n.sentTime=Date.now()-r._cppProtocol.getDeltaTime(),o({code:t,data:n})}),e,t,i,JSON.stringify(c),l,d,M,x,u,p,g,N,w,T,f,JSON.stringify(R),_,y),D=JSON.parse(L);n&&n(D.messageId)}))},e.prototype.recallMsg=function(e,t,o,n,r){var i=this;return new Promise((function(a,c){var u,p=r.user,l=r.pushContent,f=r.channelId,h=r.extra,_=r.pushConfig,S=r.disableNotification,y={conversationType:e,targetId:t,messageUId:o,sentTime:n,user:p,extra:h,channelId:f};p&&(y.user=p),h&&(y.extra=h);var m={conversationType:e,targetId:t,senderUserId:i._currentUserId,content:y,objectName:C.RECALL,messageUid:o,direction:d.SEND,status:v.UNREAD,sentTime:n,channelId:f},P=i._buildMessage(JSON.stringify(m),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){a({code:s.SUCCESS,data:P})}),(function(e){a({code:e})}),C.RECALL,JSON.stringify(y),S||!1,(null==_?void 0:_.disablePushTitle)||!1,(null==_?void 0:_.forceShowDetailContent)||!1,l||"",(null==_?void 0:_.pushData)||"",(null===(u=null==_?void 0:_.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==_?void 0:_.pushTitle)||"",g(null==_?void 0:_.iOSConfig,null==_?void 0:_.androidConfig),(null==_?void 0:_.templateId)||"",f)}))},e.prototype.getHistoryMessage=function(e,t,o,n,r,i,a){var c=this;return new Promise((function(u,p){o=o||0;var l=0===r,d=n+1,f=c._callCppProxy("getHistoryMessages",e,t,o,d,a,l,i),C=JSON.parse(f).list,g=[];C.reverse();for(var h=0;h<C.length;h++){var v=c._buildMessage(C[h].obj);g[h]=v}u({code:s.SUCCESS,data:{list:d===g.length?g.slice(1,d):g,hasMore:n<g.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,o,n,r,i){var a=this;return new Promise((function(c,u){o=o||0;a._callCppProxy("getRemoteHistoryMessages",e,t,o,n,(function(e,t){var o=JSON.parse(e).list,n=[];o.reverse();for(var r=0;r<o.length;r++){var i=a._buildMessage(o[r].obj);n[r]=i}c({code:s.SUCCESS,data:{list:n,hasMore:!!t}})}),(function(e){c({code:e})}),r,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,o,n){var r=this;return new Promise((function(i,a){var c=JSON.stringify(o);r._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,n,(function(){i(s.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,o,n){var r=this;return new Promise((function(i,a){r._callCppProxy("clearRemoteHistoryMessages",e,t,o,(function(){i(s.SUCCESS)}),(function(e){i(e)}),n)}))},e.prototype.clearMessages=function(e,t,o){var n=this;return new Promise((function(r,i){n._callCppProxy("clearMessages",e,t,o),r(s.SUCCESS)}))},e.prototype.getConversationList=function(e,t,o,n,r){var i=this;return void 0===r&&(r=""),new Promise((function(e,t){for(var o=i._callCppProxy("getConversationList",[1,3,6,7],r),n=JSON.parse(o).list,a=[],c=0;c<n.length;c++)a.push(i._buildConversation(n[c].obj));e({code:s.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,o){var n=this;return new Promise((function(r,i){var a=n._callCppProxy("getConversation",e,t,o);if(a)r({code:s.SUCCESS,data:n._buildConversation(a)});else{var c=n._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,o),u=void 0;try{u=JSON.parse(c).list}catch(e){n._logger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=n._buildMessage(u[0].obj));var l=n._callCppProxy("getConversationNotificationStatus",e,t,o),d=n._callCppProxy("getConversationTopStatus",e,t,o);r({code:s.SUCCESS,data:{conversationType:e,targetId:t,channelId:o,unreadMessageCount:0,latestMessage:p,notificationStatus:l?f.OPEN:f.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,o){var n=this._callCppProxy("removeConversation",e,t,o);return this._logger.info("removeConversation result -> ".concat(n)),Promise.resolve(n?s.SUCCESS:s.UNKNOWN)},e.prototype.clearConversations=function(e,t){var o=this;return new Promise((function(n,r){var i=[];i=_(e)?e:[a.PRIVATE,a.GROUP,a.SYSTEM,a.PUBLIC_SERVICE],o._callCppProxy("clearConversations",i,t),n(s.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,o){var n=this._callCppProxy("getTotalUnreadCount",t,o,e);return Promise.resolve({code:s.SUCCESS,data:n})},e.prototype.getConversationUnreadCount=function(e,t,o){var n=this;return void 0===o&&(o=""),new Promise((function(r){var i=n._callCppProxy("getUnreadCount",e,t,o);r({code:s.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,o){var n=this;return void 0===o&&(o=""),new Promise((function(r,i){n._callCppProxy("clearUnreadCount",e,t,o),r(s.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,o,n){var r=this;return new Promise((function(i,a){r._callCppProxy("clearUnreadCountByTimestamp",e,t,o,n),i(s.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,o){var n=this;return new Promise((function(r,i){var a=n._callCppProxy("getTheFirstUnreadMessage",e,t,o),c=n._buildMessage(a);r({code:s.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,o,n){var r=this;return void 0===n&&(n=""),new Promise((function(i,a){r._logger.info("setConversationToTop",e,t,o,n,true),r._callCppProxy("setConversationToTop",e,t,o,n,true),i(s.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,o,n){var r=this;return new Promise((function(i,a){r._callCppProxy("setConversationHidden",e,t,o,n),i(s.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,o,n){var r=this;return new Promise((function(i,a){r._logger.info("setConversationNotificationStatus",e,t,o,n),r._callCppProxy("setConversationNotificationStatus",e,t,o,(function(){i(s.SUCCESS)}),i,n)}))},e.prototype.setConversationStatus=function(e,t,o,n,r){var i=this;return new Promise((function(a,c){i._logger.info("setConversationStatus",e,t,o,n,r,true),i._callCppProxy("setConversationStatus",e,t,o,n,(function(){a(s.SUCCESS)}),a,r,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,o){var n=this;return new Promise((function(r,i){var a=n._callCppProxy("getConversationNotificationStatus",e,t,o);r({code:s.SUCCESS,data:a?f.OPEN:f.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,o,n){var r=this;return new Promise((function(i,a){n=n||[1,3,6,7];for(var c=r._callCppProxy("searchConversationByContent",n,e,t,o),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=r._buildConversation(u[l].obj);i({code:s.SUCCESS,data:p})}))},e.prototype.searchMessageByContent=function(e,t,o,n,r,i,a){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,o,n,r,1,(function(e,t){for(var o=e?JSON.parse(e).list:[],n=[],r=0;r<o.length;r++)n[r]=c._buildMessage(o[r].obj);i({code:s.SUCCESS,data:{messages:n,count:t}})}),a)}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("addToBlacklist",e,(function(){o(s.SUCCESS)}),o)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("removeFromBlacklist",e,(function(){o(s.SUCCESS)}),o)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,o){e._callCppProxy("getBlacklist",(function(e){t({code:s.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("getBlacklistStatus",e,(function(e){o({code:s.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},e.prototype.insertMessage=function(e,t,o){var n=this,r=o.content,i=o.senderUserId,a=o.messageType,c=o.messageDirection,u=o.readStatus,p=o.sentStatus,l=o.sentTime,d=o.searchContent,f=o.isUnread,C=o.messageUId,g=o.disableNotification,h=o.canIncludeExpansion,v=o.expansionMsg,_=o.channelId;return r=JSON.stringify(r),new Promise((function(o,S){var y=f?0:1,m=n._callCppProxy("insertMessage",e,t,i,a,r,(function(){}),(function(e){o({code:e})}),c,u,p,l,d,y,C,g,h,v,_);n._logger.info("after insert msg",m);var P=n._buildMessage(m,{isOffLineMessage:!1});P.messageUId=C,P.sentTime=l,o({code:-1===P.messageId?s.MSG_INSERT_ERROR:s.SUCCESS,data:P})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("deleteMessages",e),o(s.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,o,n,r){var i=this;return new Promise((function(a,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,o,n,r),a(s.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(o,n){var r=t._callCppProxy("getMessage",e);t._logger.info("getMessage ===>",r);var i=t._buildMessage(r,{isOffLineMessage:!1});o({code:s.SUCCESS,data:i})}))},e.prototype.setMessageContent=function(e,t,o){var n=this;return new Promise((function(r,i){t=JSON.stringify(t),n._callCppProxy("setMessageContent",e,t,o),r(s.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,o){var n=this;return new Promise((function(r,i){n._callCppProxy("setMessageSearchField",e,t,o),r(s.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var o=this;return new Promise((function(n,r){o._callCppProxy("setMessageSentStatus",e,t),n(s.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var o=this;return new Promise((function(n,r){o._callCppProxy("setMessageReceivedStatus",e,t),n(s.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],o=t.conversationType,n=t.targetId,r=t.isTop,i=t.notificationStatus,s=t.channelId;if(void 0!==r&&void 0===i)return this.setConversationToTop(o,n,r,s);if(void 0!==i&&void 0===r){var a=i===f.OPEN;return this.setConversationNotificationStatus(o,n,a,s)}a=i===f.OPEN;return this.setConversationStatus(o,n,a,r,s)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,o){var n=this;return new Promise((function(r,i){n._callCppProxy("sendReadReceipt",e,o||"",t,(function(){t.forEach((function(e){n._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(n._callCppProxy("getMessage",e)).messageId;n.setMessageReceivedStatus(t,1)}catch(t){n._logger.warn("format message error, messageUId: "+e)}})),r({code:s.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getMessageReader=function(e,t,o){var n=this;return new Promise((function(r,i){n._callCppProxy("getMessageReader",e,o,t,(function(e,o){n._logger.info("getMessageReader -> ",e,o);var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;i.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:i.length,totalCount:o};n._updateReadReceiptInfo(t,c),r({code:s.SUCCESS,data:{list:i,totalMemberCount:o}})}),(function(e){r({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var o=this;return new Promise((function(n,r){o._callCppProxy("clearMessages",a.CHATROOM,e,""),o._callCppProxy("joinChatRoom",e,t,(function(){n(s.SUCCESS)}),n)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("quitChatRoom",e,(function(){o(s.SUCCESS)}),o)}))},e.prototype.getChatroomInfo=function(e,t,o){var n=this;return new Promise((function(r,i){n._callCppProxy("getChatroomInfo",e,t,o,(function(e,t){var o=e?JSON.parse(e).list:[],n=[];if(o.length>0)for(var i=0;i<o.length;i++)n.push(JSON.parse(o[i].obj));r({code:s.SUCCESS,data:{userInfos:n,userCount:t}})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,o,n){var r=this;return new Promise((function(i,a){r._callCppProxy("getChatroomHistoryMessage",e,t,o,n,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var o=t.list;if(o&&o.length)try{t.list=o.map((function(e){return r._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:s.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var o=this;return new Promise((function(n,r){var i='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';o._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){n(s.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var o=this;return new Promise((function(n){o._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var o=this,n=[t.key];return new Promise((function(r,i){o._callCppProxy("deleteChatroomKV",e,n,!!t.isOverwrite,(function(){r(s.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var o=this;return new Promise((function(n){var r=t.entries.map((function(e){return e.key}));o._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return L(this,void 0,void 0,(function(){var o;return D(this,(function(n){switch(n.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(o=n.sent()).code===s.SUCCESS?[2,{code:s.SUCCESS,data:o.data?o.data[t]:null}]:[2,{code:o.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}o({code:s.SUCCESS,data:t})}),(function(e){o({code:e})}))}))},e.prototype.getFileToken=function(e,t,o,n){var r=this;return o=o||"",n=n||"",new Promise((function(i){var a;a=n&&"uploads"!==n?t||"":S(e,t),r._callCppProxy("getUploadToken",e,a,o,n,(function(e,t,o,n,r,c,u,p,l,d,f,C,g,h,v,_,S,y){i({code:s.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:o,path:n,osskeyId:r,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:f,s3Policy:C,s3Signature:g,s3BucketName:h,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,o,n){var r=this;return new Promise((function(i){r._callCppProxy("getDownloadUrl",e,o,n,t-1,(function(e){i({code:s.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,o){var n=e._callCppProxy("clearData");t({code:s.SUCCESS,data:n})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||o(R.getPath("userData"));return j(e)},e.prototype.getVoIPKey=function(e,t){var o=this;return new Promise((function(n,r){o._callCppProxy("getVoIPKey",e,t,"",(function(e){n({code:s.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.joinRTCRoom=function(e,t,o,n,r,i){var a=this;return new Promise((function(c){var u=r?JSON.stringify(r):"",p=i?JSON.stringify(i):"";a._callCppProxy("joinRTCRoom",e,t,o||0,n||y.KICK,(function(e,t,o,n){var r=JSON.parse(e).list,i={token:t,sessionId:o,users:{},roomInfo:W(n),kvEntries:[]};r.forEach((function(e){var t=e.id,o=e.data;i.users[t]=o[0]||{}})),c({code:s.SUCCESS,data:i})}),(function(e){a._logger.error("joinRTCRoom error -> ".concat(e)),c({code:e})}),"","",u,p)}))},e.prototype.quitRTCRoom=function(e){var t=this;return new Promise((function(o){t._callCppProxy("exitRTCRoom",e,(function(){o(s.SUCCESS)}),o)}))},e.prototype.rtcPing=function(e,t,o){var n=this;return new Promise((function(t){n._callCppProxy("sendRTCPing",e,(function(){t(s.SUCCESS)}),t)}))},e.prototype.getRTCRoomInfo=function(e){var t=this;return new Promise((function(o){t._callCppProxy("getRTCResouce",e,2,(function(e){o({code:s.SUCCESS,data:JSON.parse(e)})}),(function(e){o({code:e})}))}))},e.prototype.getRTCUserInfoList=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("getRTCResouce",e,1,(function(e){var t=JSON.parse(e).list,n={users:{}};t.forEach((function(e){var t=e.id,o=e.data;n.users[t]=o[0]||{}})),o({code:s.SUCCESS,data:n})}),(function(e){o({code:e})}))}))},e.prototype.getRTCUserInfo=function(e){throw new Error("Method not implemented.")},e.prototype.setRTCUserInfo=function(e,t,o){var n=this;return new Promise((function(r,i){n._callCppProxy("setRTCInnerData",e,m.PERSON,t,o,"","",(function(){r(s.SUCCESS)}),r)}))},e.prototype.removeRTCUserInfo=function(e,t){var o=this;return new Promise((function(n,r){o._callCppProxy("deleteRTCInnerData",e,m.PERSON,t,"","",(function(){n(s.SUCCESS)}),n)}))},e.prototype.setRTCData=function(e,t,o,n,r,i){var a=this;return new Promise((function(c){var u={room_innder:function(e,t,o,n,r,i,s){a._callCppProxy("setRTCInnerData",e,m.ROOM,t,o,n,r,i,s)},room_outer:function(e,t,o,n,r,i,s){a._callCppProxy("setRTCOuterData",e,m.ROOM,t,o,n,r,i,s)},user_innder:function(e,t,o,n,r,i,s){a._callCppProxy("setRTCInnerData",e,m.PERSON,t,o,n,r,i,s)},user_outer:function(e,t,o,n,r,i,s){a._callCppProxy("setRTCOuterData",e,m.PERSON,t,o,n,r,i,s)}},p=m.PERSON===r?"user":"room",l=n?"inner":"outer",d=u["".concat(p,"_").concat(l)];if(d){var f=(null==i?void 0:i.content)?JSON.stringify(i.content):"",C=(null==i?void 0:i.name)||"";d(e,t,o,C,f,(function(){c(s.SUCCESS)}),(function(e){c(e)}))}}))},e.prototype.setRTCTotalRes=function(e,t,o,n,r){var i=this;return new Promise((function(a){var c=t.name,u=t.content;i._callCppProxy("setUserResource",e,c,u,n,o,r,(function(){return a(s.SUCCESS)}),a)}))},e.prototype.setRTCCDNUris=function(e,t,o){var n=this;return new Promise((function(r){n._callCppProxy("setRTCCDNUris",e,t,o,(function(){return r(s.SUCCESS)}))}))},e.prototype.getRTCData=function(e,t,o,n){var r=this;return new Promise((function(i){var a={room_inner:function(e,t,o,n){r._callCppProxy("getRTCInnerData",e,m.ROOM,t,o,n).getRTCInnerData()},room_outer:function(e,t,o,n){r._callCppProxy("getRTCOuterData",e,m.ROOM,t,o,n)}},c=m.PERSON===n?"user":"room",u=o?"inner":"outer",p=a["".concat(c,"_").concat(u)];p&&p(e,t,(function(e){var t=JSON.parse(e),o={};t.list.forEach((function(e){var t=Object.keys(e)[0],n=Object.values(e)[0];o[t]=n})),i({code:s.SUCCESS,data:o})}),(function(e){i({code:e})}))}))},e.prototype.removeRTCData=function(e,t,o,n,r){var i=this;return new Promise((function(a){i._callCppProxy;var c={room_inner:function(e,t,o,n,r,s){i._callCppProxy("deleteRTCInnerData",e,m.ROOM,t,o,n,r,s)},room_outer:function(e,t,o,n,r,s){i._callCppProxy("deleteRTCOuterData",e,m.ROOM,t,o,n,r,s)},user_inner:function(e,t,o,n,r,s){i._callCppProxy("deleteRTCInnerData",e,m.PERSON,t,o,n,r,s)},user_outer:function(e,t,o,n,r,s){i._callCppProxy("deleteRTCOuterData",e,m.PERSON,t,o,n,r,s)}},u=m.PERSON===n?"user":"room",p=o?"inner":"outer",l=c["".concat(u,"_").concat(p)];if(l){var d=(null==r?void 0:r.content)?JSON.stringify(r.content):"",f=(null==r?void 0:r.name)||"";l(e,t,f,d,(function(){a(s.SUCCESS)}),(function(e){a(e)}))}}))},e.prototype.setRTCOutData=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getRTCOutData=function(e,t){throw new Error("Method not implemented.")},e.prototype.getRTCToken=function(e,t,o){var n=this;return new Promise((function(t){n._callCppProxy("getRTCToken",e,(function(e){t({code:s.SUCCESS,data:{rtcToken:e}})}),(function(e){t({code:e})}))}))},e.prototype.setRTCState=function(e,t){var o=this;return new Promise((function(n){o._callCppProxy("setRTCUserState",e,t,(function(){n(s.SUCCESS)}),n)}))},e.prototype.getRTCUserList=function(e){var t=this;return new Promise((function(o){t._callCppProxy("getRTCUsers",e,1,(function(e){o({code:s.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("deleteTag",e,(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(o,n){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,o){var n=e._callCppProxy("getTags");e._logger.info("getTagList -> ",n);var r=e._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:s.SUCCESS,data:r})}))},e.prototype.addTagForConversations=function(e,t){var o=this;return new Promise((function(n,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));o._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var o=this;return new Promise((function(n,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),o._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var o=this;return new Promise((function(n,r){o._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,o,n){var r=this;return new Promise((function(i,a){var c=r._callCppProxy("getConversationsForTagByPage",e,t,o||20,n||"");r._logger.info("getConversationListByTag -> ",c);var u=r._convertResultList(c,(function(e){return w(w({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:s.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var o=this;return new Promise((function(n,r){var i=o._callCppProxy("getConversationUnreadCountForTag",e,t);o._logger.info("getUnreadCountByTag -> ",i),n({code:s.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,o){var n=this;return new Promise((function(r,i){n._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",o.isTop||!1,(function(){r({code:s.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(o,n){var r=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._logger.info("getTagsForConversation -> ",r);var i=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));o({code:s.SUCCESS,data:i})}))},e.prototype.joinLivingRoomAsAudience=function(e,t,o){return L(this,void 0,void 0,(function(){var o=this;return D(this,(function(n){return[2,new Promise((function(n,r){o._cppProtocol.audienceJoinRoom(e,t,(function(e,t){k.info("joinLivingRoomAsAudience data:",e,t),n({data:{token:e,kvEntries:V(t)},code:s.SUCCESS})}),(function(e){n({code:e})}))}))]}))}))},e.prototype.quitLivingRoomAsAudience=function(e){var t=this;return new Promise((function(o,n){t._cppProtocol.audienceLeaveRoom(e,(function(){o(s.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.switchLivingRoomRole=function(e,t,o){var n=this;return void 0===o&&(o=P.AUDIO_AND_VIDEO),new Promise((function(r,i){n._cppProtocol.switchRole(e,o,t,"","",(function(e,t,o,n,i){k.info("switchLivingRoomRole data:",e,t,o,n,i);var a=JSON.parse(e).list,c={token:t,sessionId:o,users:{},roomInfo:W(n),kvEntries:V(i)};a.forEach((function(e){var t=e.id,o=e.data;c.users[t]=o[0]||{}})),r({code:s.SUCCESS,data:c})}),(function(e){r({code:e})}))}))},e.prototype.getRTCJoinedUserInfo=function(e){var t=this;return new Promise((function(e){t._callCppProxy("queryJoinedRoom",(function(o){t._logger.info("getRTCJoinedUserInfo -> ",o);var n=JSON.parse(o).list[0];e(n?{code:s.SUCCESS,data:[JSON.parse(n.obj)]}:{code:s.SUCCESS})}),(function(t){e({code:t})}))}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.requestRoomPK=function(e){var t=this;return new Promise((function(o,n){var r=e.roomId,i=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteTimeout,p=e.inviteInfo;t._callCppProxy("livePKInvitation",r,a,i,p,c,u,(function(){o(s.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.cancelRoomPK=function(e){var t=this;return new Promise((function(o,n){var r=e.roomId,i=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteInfo;t._callCppProxy("livePKCancel",r,a,i,u,c,(function(){o(s.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.responseRoomPK=function(e){var t=this;return new Promise((function(o,n){var r=e.roomId,i=e.inviteUserId,a=e.inviteRoomId,c=e.inviteSessionId,u=e.content,p=e.key,l=e.value,d=e.agree?1:0;t._callCppProxy("livePKAnswer",r,d,i,a,c,u,p,l,(function(){o(s.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.endRoomPK=function(e){var t=this;return new Promise((function(o,n){var r=e.roomId,i=e.endRoomId,a=e.sessionId,c=e.content,u=e.keys;t._callCppProxy("livePKHangup",r,i,a,c,u,(function(){o(s.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(o,n){var r=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",r,i,(function(){o(s.SUCCESS)}),(function(e){o(e)}))}))},e}(),G=function(e){return function(e,t){return k.setLogLevel(null==t?void 0:t.logLevel),k.setLogStdout(null==t?void 0:t.logStdout),new q(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(b,e)};export{G as default};
|
|
1
|
+
import{platform as e,arch as t}from"os";import{resolve as n}from"path";import{Logger as o,ConnectionStatus as r,LogLevel as i,ErrorCode as s,ConversationType as a,SEND_MESSAGE_TYPE_OPTION as c,isObject as u,isUndefined as p,pushJSONToConfigs as l,MessageDirection as d,NotificationStatus as f,MessageType as C,pushConfigsToJSON as h,MentionedType as v,ReceivedStatus as g,isArray as _,getUploadFileName as S,RTCJoinType as y,RTCApiType as m,LiveType as P}from"@rongcloud/engine";import{ipcMain as E,app as R}from"electron";import{existsSync as T,readFileSync as I,writeFileSync as N}from"fs";import{createHash as O}from"crypto";import{request as U}from"http";import{Agent as M,request as x}from"https";var b=process.versions.electron.replace(/\.\d+$/,""),w=n(__dirname,"binding","electron-v".concat(b,"-").concat(e(),"-").concat(t(),".node")),L=null;try{L=require(w)}catch(e){console.error("error ->",w,"\n",e)}var D=L,A=function(){return A=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},A.apply(this,arguments)};function J(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function k(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function H(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var F,j=new o("RCMain"),B=null,K=function(){var n,o=Date.now(),r=[t(),e(),process.pid,o,Math.floor(Math.random()*o)].join("__");return n=r,O("md5").update(n).digest("hex")},V=function(e){if(B)return B;var t=n(e,"deviceId");return j.debug("deviceIdPath -> ".concat(t)),T(t)?B=I(t).toString():(B=K(),j.debug("createDeviceId -> ".concat(B)),N(t,B),B)},q=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,n){return F?(F.stop(),F):F=new e(t,n)},e.prototype.start=function(e){var t=this,n=this,o=function(){var r=t._isFirstPing?0:15e3;n._timerId=setTimeout((function(){n._isFirstPing=!1,j.debug("current lossCount: "+n._lossCount),n._hasPingRes?(e(),n._hasPingRes=!1,o()):n._lossCount<4?(n._lossCount++,e(),o()):n._reconnect()}),r)};o()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){j.debug("receive pong"),this._hasPingRes=e,this._lossCount=0},e}(),W=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,n,o,r){var i=JSON.stringify(o);j.info("MsgExpansion._setToProtocol ===>",e,t,n,i,r),this._cppProto.setMessageExtension(e,t,n,i,r)},e.prototype.setLocalFromReceiveMsg=function(e){j.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,n=e.conversationType,o=e.targetId,r=e.messageUId,i=e.expansion,s=e.sentTime,a={};for(var c in i)a[c]={v:"",ts:0},a[c].v=i[c],a[c].ts=s;this._setToProtocol(n,o,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){j.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,n=e.conversationType,o=e.targetId;e.messageUId;var r=e.content,i=e.sentTime,s=r,a=s.put,c=this._cppProto.getMessage(s.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(j.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var l in a){var d=p[l];d&&d.ts<i-this._setTime?(d.v=a[l],d.ts=i-this._setTime):(p[l]={v:"",ts:0},p[l].v=a[l],p[l].ts=i-this._setTime)}s.del&&s.del.forEach((function(e){delete p[e]})),this._setToProtocol(n,o,s.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),n={};for(var o in t)n[o]=t[o].v;return n},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),n=JSON.parse(t||"{}"),o={};for(var r in n)o[r]=n[r].v;return o},e}(),G=function(e){var t=[];return JSON.parse(e).list.forEach((function(e){t.push(JSON.parse(e.obj))})),t},Y=function(e){return JSON.parse(e).list.map((function(e){return{key:Object.keys(e)[0],value:Object.values(e)[0]}}))},X=null;function z(e,t,n,o,r){return void 0===r&&(r=!0),J(this,void 0,void 0,(function(){var i;return k(this,(function(s){switch(s.label){case 0:return X?[2,X]:(X=function(e,t,n,o,r){return void 0===r&&(r=!0),J(this,void 0,void 0,(function(){var i,s,a,c;return k(this,(function(u){switch(u.label){case 0:i=function(i,s){var a,c,u,p,l;return k(this,(function(s){switch(s.label){case 0:return a="".concat(t[i],"/navi.json?r=").concat(Date.now()),c="token=".concat(encodeURIComponent(o),"&v=").concat((d=e,d.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.3.3"),j.info("request navi -> url: ".concat(a,", body: ").concat(c)),[4,new Promise((function(e){var t=/^https/.test(a),o={headers:{appId:n},method:"POST"};t&&(o.rejectUnauthorized=r,o.agent=new M(o));var i=(t?x:U)(a,o,(function(t){var n=t.statusCode,o="";t.setEncoding("utf8"),t.on("data",(function(e){o+=e})),t.on("end",(function(){e({status:n||0,data:o})}))}));i.on("error",(function(t){j.error(t),e({status:0})})),i.write(c),i.end()}))];case 1:if(200!==(u=s.sent()).status)return j.error("request navi failed -> ".concat(a)),u.data&&j.error(u.data),[2,"continue"];j.info("request navi success -> ".concat(a));try{return p=JSON.parse(u.data),l=/^https/.test(a)?"https":"http",p.protocol=l,[2,{value:p}]}catch(e){j.error("parse navi err => ".concat(u.data))}return[2]}var d}))},s=0,a=t.length,u.label=1;case 1:return s<a?[5,i(s,a)]:[3,4];case 2:if("object"==typeof(c=u.sent()))return[2,c.value];u.label=3;case 3:return s+=1,[3,1];case 4:return[2,null]}}))}))}(e,t,n,o,r),[4,X]);case 1:return i=s.sent(),X=null,[2,i]}}))}))}var Q=function(){function e(e,t,n){void 0===t&&(t=""),void 0===n&&(n=!1);var o=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=n,this._currentToken="",this._connectionStatus=r.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=r.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._version="5.3.3",this.naviInfo=null,this._logger={debug:this._superLog.bind(this,"debug",i.DEBUG),info:this._superLog.bind(this,"info",i.INFO),warn:this._superLog.bind(this,"warn",i.WARN),error:this._superLog.bind(this,"error",i.ERROR),fatal:this._superLog.bind(this,"fatal",i.FATAL)},this._senders={},E.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return J(o,void 0,void 0,(function(){var o,r,i,a;return k(this,(function(c){switch(c.label){case 0:if((a=this._logger).debug.apply(a,H(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],n,!1)),"function"!=typeof(o=this[t]))return e.returnValue=s.NOT_SUPPORT,[2];r=s.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,o.call.apply(o,H([this],n,!1))];case 2:return r=c.sent(),[3,4];case 3:return i=c.sent(),this._logger.error("call main process method `".concat(t,"` failed.")),this._logger.error(i),[3,4];case 4:return e.returnValue=r,[2]}}))}))})),E.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return J(o,void 0,void 0,(function(){var o,i,a,c,u,p=this;return k(this,(function(l){switch(l.label){case 0:if((u=this._logger).debug.apply(u,H(["__RC_CHANNEL_CALL_MAIN__",t,n],r,!1)),"function"!=typeof(o=this[n]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,s.NOT_SUPPORT),[2];"sendMessage"===n&&(i=r.pop(),r.push((function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",i,t)}))),a=s.EXTRA_METHOD_UNDEFINED,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,o.call.apply(o,H([this],r,!1))];case 2:return a=l.sent(),[3,4];case 3:return c=l.sent(),this._logger.error("call main process method `".concat(n,"` failed.")),this._logger.error(c),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),E.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];(n=o._logger).debug.apply(n,H(["__RC_CHANNEL_CALL_MAIN__",t],r,!1));var s=o[t];if("function"==typeof s)try{s.call.apply(s,H([o],r,!1))}catch(e){o._logger.error("call main process method `".concat(t,"` failed.")),o._logger.error(e)}else o._logger.error("cannot not found method: ".concat(t))})),E.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new W(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,n,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,o)}catch(t){(n=this._logger).error.apply(n,H([t,e],o,!1))}},e.prototype._superLog=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];if(j[e]&&j[e].apply(j,n),t!==i.DEBUG){var r=Object.keys(this._senders);if(r.length>0){var s=n.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[r[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,s,"RCMain")}}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];(t=this._logger).info.apply(t,H(["callExtra -> ".concat(e)],n,!1));var r=this[e];if(!r)return this._logger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:s.EXTRA_METHOD_UNDEFINED});try{return r.call.apply(r,H([this],n,!1))}catch(e){this._logger.error(e)}return Promise.resolve({code:s.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,n,o){var r,i=this,a=this._callCppProxy("getConversationListByPage",e,t,n,o||"");try{r=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:r})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[a.PRIVATE,a.GROUP],o=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(o).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[a.PRIVATE,a.GROUP],i=this._callCppProxy("getConversationListWithAllChannelByPage",r,e,t);try{n=JSON.parse(i).list.map((function(e){return o._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,o,r,i,a){var c=0===i,u=o+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,r,c,a||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var f=0;f<d.length;f++){var C=this._buildMessage(d[f].obj);l[f]=C}}catch(e){return this._logger.error(e),Promise.resolve({code:s.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:o<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,o){void 0===o&&(o=""),this._logger.info("updateMessageReceiptStatus ->",e,t,n,o);var r=this._callCppProxy("updateMessageReceiptStatus",e,t,n,o);return Promise.resolve({code:s.SUCCESS,data:r})},e.prototype.requestNaviInfo=function(e,t,n,o){return J(this,void 0,void 0,(function(){return k(this,(function(r){return[2,z(this._initOptions.apiVersion,e,t,n,o)]}))}))},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this._naviInfo.userId},e.prototype._send2Renderer=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,H([t],n,!1))},e.prototype._send2AllRenderer=function(e,t,n){var o=this;void 0===n&&(n=[]),Object.keys(this._senders).forEach((function(r){var i=o._senders[r];n.includes(i)||o._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,t){var o=this,r=e.sender,i=r.id;if(this._senders[i]||(this._senders[i]=r,r.once("destroyed",(function(){delete o._senders[i]}))),!this._inited){this._inited=!0,this._initOptions=t,this._logger.info("init ->",t);var s=this._dbpath||n(R.getPath("userData"));this._callCppProxy("initWithAppkey",t.appkey,s),this._logger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var a=V(s);this._logger.info("deviceId -> ".concat(a)),this._callCppProxy("setDeviceId",a),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in c["RC:RcCmd"]={isCounted:!1,isPersited:!1},c){var t=c[e],n=t.isCounted,o=0;t.isPersited&&(o|=1),n&&(o|=2),"RC:TypSts"===e&&(o=16),this._logger.info("_registerMsgTypes ====>",e,o),this._callCppProxy("registerMessageType",e,o)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=JSON.parse(e);this._logger.debug("_buildMessage:",r);var i=r.channelId,s=r.conversationType,a=r.targetId,f=r.senderUserId,C=r.content,h=r.objectName,v=r.messageUid,g=r.direction,_=r.status;r.source;var S=r.messageId,y=r.sentTime,m=r.readReceiptRequest,P=r.supportExt;r.extMsg;var E,R=r.pushContent,T=r.pushTitle,I=r.pushId,N=r.pushConfig,O=r.templateId,U=r.disableTitle,M=r.forcePushDetail;if(u(C))E=C;else try{E=C?JSON.parse(C):C}catch(e){j.warn("cpp engine build messaga error:",e),E=C}var x={isCounted:!1,isPersited:!1};h in c?x=c[h]:h in this._customMessageType&&(x=this._customMessageType[h]);var b=null;P&&(b=this._msgExpansionHandler.parseReceiveExpansion(r),"conversation"!==o&&"history"!==o||(b=this._msgExpansionHandler.parseConverOrHisExpansion(r)));var w=p(n)?y<this._connectedTime:n,L={};N&&(L=l(N,I));var D=A(A({},L),{pushTitle:T,pushContent:R,pushData:R,disablePushTitle:U,forceShowDetailContent:M,templateId:O}),J={channelId:i,conversationType:s,targetId:a,senderUserId:f,content:E||{},messageType:h,messageUId:v,messageDirection:g,isOffLineMessage:w,sentTime:y,receivedTime:0,isPersited:x.isPersited,isCounted:x.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:P,expansion:P?b:null,receivedStatus:_,messageId:S,pushConfig:D};if(g===d.RECEIVE?J.receivedStatus=_:g===d.SEND&&(J.sentStatus=_),m){var k=JSON.parse(m),H=k.hasRespond,F=k.readerInfo,B={hasRespond:H,readCount:k.readCount,totalCount:k.totalCount},K=[];if(F)for(var V in F)K.push({userId:V,readTime:F[V]});B.readerList=K,J.readReceiptInfo=B}return J},e.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},i=A(A({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._logger.debug("_buildConversation",t);var n=t.channelId,o=t.conversationType,r=t.targetId,i=t.unreadCount,s=t.lastestMsg,a=t.isTop,c=t.isBlocked,u=t.matchCount,p=c?f.OPEN:f.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:i,latestMessage:-1===JSON.parse(s).messageId?null:this._buildMessage(s),hasMentioned:!1,mentionedInfo:null,notificationStatus:p,isTop:a,lastUnreadTime:0,matchCount:u}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var n=JSON.parse(e).list;return n=n.map((function(e){var n=JSON.parse(e.obj);return t?t(n):n}))},e.prototype._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n;switch(e._logger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:n=r.CONNECTING;break;case 31004:return void setTimeout((function(){e._connectResolve(s.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:n=r.DISCONNECTED;break;case 13:n=r.BLOCKED;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:n=r.NETWORK_UNAVAILABLE;break;case 30010:n=r.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===r.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:n=r.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(s.SUCCESS),e._heartbeat=q.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case r.KICKED_OFFLINE_BY_OTHER_CLIENT:n=r.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:n=r.REDIRECT;break;default:n=t}n!==r.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=n,e._sendConnectionStatus2Renderer(n)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;j.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(r.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){j.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){j.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,o,r){var i=e._buildMessage(t,{isOffLineMessage:o});if(i.messageType===C.GROUP_READ_RECEIPT_REQUEST){var s=i.content,a=s.msgId,c=s.rrn,u=s.tmn;e._updateReadReceiptInfo(a,{readCount:c,totalCount:u})}if("RC:MsgExMsg"===i.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(i),void e._sendMessageExpansion(i);if(i.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(i),i.messageType===C.SYNC_READ_STATUS){if(i.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,i.channelId||"")}var p=!0;if(0!==n||r||(p=!1),i.messageType!==C.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){var l=i.conversationType,d=i.targetId;i.messageType===C.RECALL&&i.senderUserId===e._currentUserId&&(l=i.content.conversationType||l,d=i.content.targetId||d),e._sendMessageNotification(Object.assign(i,{hasMoreMsg:p,conversationType:l,targetId:d}))}else{var f=Object.keys(e._senders).map((function(t){return e._senders[t]}));f.length>0&&e._sendMessageNotification(Object.assign(i,{hasMoreMsg:p}),f.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var n=e.channelId,o=e.content,r=o.put,i=o.del,s=o.mid,a={};r&&(a.updatedExpansion={channelId:n,messageUId:s,expansion:r}),i&&(a.deletedExpansion={channelId:n,messageUId:s,deletedKeys:i}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,o=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,r=t.targetId,i=t.status,s=t.channelId,a={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?a.notificationStatus=1===Number(t.value)?f.OPEN:f.CLOSE:a.isTop=1===Number(t.value)})),o.push({channelId:s,conversationType:n,targetId:r,updatedItems:{notificationStatus:{val:a.notificationStatus,time:0},isTop:{val:a.isTop,time:0}}})})),e._send2AllRenderer("conversation",o)}),(function(t){e._logger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._logger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){j.info("RTC Room Data Change:",t);var n=JSON.parse(t).list.map((function(e){var t=JSON.parse(e.obj);return{key:t.key,value:t.value,uid:t.operator,timestamp:t.version,status:t.isDeleted?1:0,roomId:t.roomId||""}}));e._send2AllRenderer("onRTCDataChange",n)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,n){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,n,o){var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this._callCppProxy("registerMessageType",e,r,o)},e.prototype.connect=function(e,t,n){var o=this;return this._logger.info("connect ->",e,t,n),this._currentToken===e&&this._connectionStatus===r.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(s.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,!this._promiseHandler.connect&&this._doConnect(n),new Promise((function(e,t){o._promiseHandler.connect?o._promiseHandler.connect.push({resolve:e,reject:t}):o._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=p(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._logger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop()},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,n){t({userId:e,status:n})}));var n=e.userIds||[];n.length&&this.subscribeUserStatus(n)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("subscribeUserStatus",e,(function(){n(s.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("setUserStatus",e,(function(){n(s.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getUserStatus",e,(function(e){n({code:s.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,o){var r=this,i=n.messageType,c=n.content,u=n.pushContent,p=n.pushData,l=n.directionalUserIdList,d=n.disableNotification,f=n.canIncludeExpansion,g=n.expansion,_=n.isVoipPush,S=n.pushConfig,y=n.channelId,m=n.isMentioned,P=n.mentionedType,E=n.mentionedUserIdList,R=S||{},T=R.iOSConfig,I=R.androidConfig,N=R.pushTitle,O=R.pushContent,U=R.pushData,M=R.disablePushTitle,x=R.forceShowDetailContent,b=R.templateId,w=h(T,I);return new Promise((function(n){u=O||u||"",p=U||p||"",d=d||!1,_=_||!1,N=N||"",O=O||"",U=U||"",M=M||!1,x=x||!1,f=f||!1;var h=(null==I?void 0:I.notificationId)||"";if(l=l||[],y=y||"",e===a.GROUP&&m&&c&&(c.mentionedInfo={userIdList:E,type:P||v.ALL}),e===a.GROUP&&i===C.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var S in c.receiptMessageDic)l.push(S);var R={};for(var S in g)R[S]={v:""},R[S].v=g[S];var T=b||"",L=r._callCppProxy("sendMessage",(function(e,t){var o=r._buildMessage(e,{isOffLineMessage:!1});return t===s.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===o.messageType&&r._msgExpansionHandler.setLocalFromExtMsg(o),o.canIncludeExpansion&&r._msgExpansionHandler.setLocalFromReceiveMsg(o),n({code:s.SUCCESS,data:o}))}),(function(e,t){var o=r._buildMessage(e,{isOffLineMessage:!1});return o.sentTime=Date.now()-r._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,i,JSON.stringify(c),l,d,M,x,u,p,h,N,w,T,f,JSON.stringify(R),_,y),D=JSON.parse(L);o&&o(D.messageId)}))},e.prototype.recallMsg=function(e,t,n,o,r){var i=this;return new Promise((function(a,c){var u,p=r.user,l=r.pushContent,f=r.channelId,v=r.extra,_=r.pushConfig,S=r.disableNotification,y=r.isDelete,m={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:p,extra:v,channelId:f,isDelete:y||!1};p&&(m.user=p),v&&(m.extra=v);var P={conversationType:e,targetId:t,senderUserId:i._currentUserId,content:m,objectName:C.RECALL,messageUid:n,direction:d.SEND,status:g.UNREAD,sentTime:o,channelId:f},E=i._buildMessage(JSON.stringify(P),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){a({code:s.SUCCESS,data:E})}),(function(e){a({code:e})}),C.RECALL,JSON.stringify(m),S||!1,(null==_?void 0:_.disablePushTitle)||!1,(null==_?void 0:_.forceShowDetailContent)||!1,l||"",(null==_?void 0:_.pushData)||"",(null===(u=null==_?void 0:_.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==_?void 0:_.pushTitle)||"",h(null==_?void 0:_.iOSConfig,null==_?void 0:_.androidConfig),(null==_?void 0:_.templateId)||"",f)}))},e.prototype.getHistoryMessage=function(e,t,n,o,r,i,a){var c=this;return new Promise((function(u,p){n=n||0;var l=0===r,d=o+1,f=c._callCppProxy("getHistoryMessages",e,t,n,d,a,l,i),C=JSON.parse(f).list,h=[];C.reverse();for(var v=0;v<C.length;v++){var g=c._buildMessage(C[v].obj);h[v]=g}u({code:s.SUCCESS,data:{list:d===h.length?h.slice(1,d):h,hasMore:o<h.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,o,r,i){var a=this;return new Promise((function(c,u){n=n||0;a._callCppProxy("getRemoteHistoryMessages",e,t,n,o,(function(e,t){var n=JSON.parse(e).list,o=[];n.reverse();for(var r=0;r<n.length;r++){var i=a._buildMessage(n[r].obj);o[r]=i}c({code:s.SUCCESS,data:{list:o,hasMore:!!t}})}),(function(e){c({code:e})}),r,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,n,o){var r=this;return new Promise((function(i,a){var c=JSON.stringify(n);r._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,o,(function(){i(s.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(i,a){r._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){i(s.SUCCESS)}),(function(e){i(e)}),o)}))},e.prototype.clearMessages=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("clearMessages",e,t,n),r(s.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,o,r){var i=this;return void 0===r&&(r=""),new Promise((function(e,t){for(var n=i._callCppProxy("getConversationList",[1,3,6,7],r),o=JSON.parse(n).list,a=[],c=0;c<o.length;c++)a.push(i._buildConversation(o[c].obj));e({code:s.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,n){var o=this;return new Promise((function(r,i){var a=o._callCppProxy("getConversation",e,t,n);if(a)r({code:s.SUCCESS,data:o._buildConversation(a)});else{var c=o._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){o._logger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=o._buildMessage(u[0].obj));var l=o._callCppProxy("getConversationNotificationStatus",e,t,n),d=o._callCppProxy("getConversationTopStatus",e,t,n);r({code:s.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?f.OPEN:f.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var o=this._callCppProxy("removeConversation",e,t,n);return this._logger.info("removeConversation result -> ".concat(o)),Promise.resolve(o?s.SUCCESS:s.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o,r){var i=[];i=_(e)?e:[a.PRIVATE,a.GROUP,a.SYSTEM,a.PUBLIC_SERVICE],n._callCppProxy("clearConversations",i,t),o(s.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:s.SUCCESS,data:o})},e.prototype.getConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r){var i=o._callCppProxy("getUnreadCount",e,t,n);r({code:s.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r,i){o._callCppProxy("clearUnreadCount",e,t,n),r(s.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(i,a){r._callCppProxy("clearUnreadCountByTimestamp",e,t,n,o),i(s.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var o=this;return new Promise((function(r,i){var a=o._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=o._buildMessage(a);r({code:s.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(i,a){r._logger.info("setConversationToTop",e,t,n,o,true),r._callCppProxy("setConversationToTop",e,t,n,o,true),i(s.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,o){var r=this;return new Promise((function(i,a){r._callCppProxy("setConversationHidden",e,t,n,o),i(s.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,o){var r=this;return new Promise((function(i,a){r._logger.info("setConversationNotificationStatus",e,t,n,o),r._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){i(s.SUCCESS)}),i,o)}))},e.prototype.setConversationStatus=function(e,t,n,o,r){var i=this;return new Promise((function(a,c){i._logger.info("setConversationStatus",e,t,n,o,r,true),i._callCppProxy("setConversationStatus",e,t,n,o,(function(){a(s.SUCCESS)}),a,r,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var o=this;return new Promise((function(r,i){var a=o._callCppProxy("getConversationNotificationStatus",e,t,n);r({code:s.SUCCESS,data:a?f.OPEN:f.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,o){var r=this;return new Promise((function(i,a){o=o||[1,3,6,7];for(var c=r._callCppProxy("searchConversationByContent",o,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=r._buildConversation(u[l].obj);i({code:s.SUCCESS,data:p})}))},e.prototype.searchMessageByContent=function(e,t,n,o,r,i,a){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=c._buildMessage(n[r].obj);i({code:s.SUCCESS,data:{messages:o,count:t}})}),a)}))},e.prototype.getUnreadMentionedMessages=function(e,t,n){for(var o=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,n)).list,r=0;r<o.length;r++)o[r]=this._buildMessage(o[r].obj);return o},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addToBlacklist",e,(function(){n(s.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("removeFromBlacklist",e,(function(){n(s.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:s.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:s.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var o=this,r=n.content,i=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,f=n.isUnread,C=n.messageUId,h=n.disableNotification,v=n.canIncludeExpansion,g=n.expansionMsg,_=n.channelId;return r=JSON.stringify(r),new Promise((function(n,S){var y=f?0:1,m=o._callCppProxy("insertMessage",e,t,i,a,r,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,C,h,v,g,_);o._logger.info("after insert msg",m);var P=o._buildMessage(m,{isOffLineMessage:!1});P.messageUId=C,P.sentTime=l,n({code:-1===P.messageId?s.MSG_INSERT_ERROR:s.SUCCESS,data:P})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteMessages",e),n(s.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,o,r){var i=this;return new Promise((function(a,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,n,o,r),a(s.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getMessage",e);t._logger.info("getMessage ===>",r);var i=t._buildMessage(r,{isOffLineMessage:!1});n({code:s.SUCCESS,data:i})}))},e.prototype.setMessageContent=function(e,t,n){var o=this;return new Promise((function(r,i){t=JSON.stringify(t),o._callCppProxy("setMessageContent",e,t,n),r(s.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("setMessageSearchField",e,t,n),r(s.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSentStatus",e,t),o(s.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageReceivedStatus",e,t),o(s.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,n,o){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,o=t.targetId,r=t.isTop,i=t.notificationStatus,s=t.channelId;if(void 0!==r&&void 0===i)return this.setConversationToTop(n,o,r,s);if(void 0!==i&&void 0===r){var a=i===f.OPEN;return this.setConversationNotificationStatus(n,o,a,s)}a=i===f.OPEN;return this.setConversationStatus(n,o,a,r,s)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){o._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(o._callCppProxy("getMessage",e)).messageId;o.setMessageReceivedStatus(t,1)}catch(t){o._logger.warn("format message error, messageUId: "+e)}})),r({code:s.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getMessageReader=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("getMessageReader",e,n,t,(function(e,n){o._logger.info("getMessageReader -> ",e,n);var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),n=t.id,o=t.time;i.push({userId:n,readTime:o}),a[n]=o}));var c={readerInfo:a,readCount:i.length,totalCount:n};o._updateReadReceiptInfo(t,c),r({code:s.SUCCESS,data:{list:i,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("clearMessages",a.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){o(s.SUCCESS)}),o)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("quitChatRoom",e,(function(){n(s.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],o=[];if(n.length>0)for(var i=0;i<n.length;i++)o.push(JSON.parse(n[i].obj));r({code:s.SUCCESS,data:{userInfos:o,userCount:t}})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,o){var r=this;return new Promise((function(i,a){r._callCppProxy("getChatroomHistoryMessage",e,t,n,o,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return r._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:s.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(o,r){var i='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';n._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){o(s.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,o=[t.key];return new Promise((function(r,i){n._callCppProxy("deleteChatroomKV",e,o,!!t.isOverwrite,(function(){r(s.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(o){var r=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return J(this,void 0,void 0,(function(){var n;return k(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===s.SUCCESS?[2,{code:s.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:s.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,o){var r=this;return n=n||"",o=o||"",new Promise((function(i){var a;a=o&&"uploads"!==o?t||"":S(e,t),r._callCppProxy("getUploadToken",e,a,n,o,(function(e,t,n,o,r,c,u,p,l,d,f,C,h,v,g,_,S,y){i({code:s.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:o,osskeyId:r,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:f,s3Policy:C,s3Signature:h,s3BucketName:v,stcAuthorization:g,stcContentSha256:_,stcDate:S,stcBucketName:y}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,o){var r=this;return new Promise((function(i){r._callCppProxy("getDownloadUrl",e,n,o,t-1,(function(e){i({code:s.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("clearData");t({code:s.SUCCESS,data:o})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||n(R.getPath("userData"));return V(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("getVoIPKey",e,t,"",(function(e){o({code:s.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},e.prototype.joinRTCRoom=function(e,t,n,o,r,i){var a=this;return new Promise((function(c){var u=r?JSON.stringify(r):"",p=i?JSON.stringify(i):"";a._callCppProxy("joinRTCRoom",e,t,n||0,o||y.KICK,(function(e,t,n,o,r,i){var a=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:Y(o),kvEntries:[],offlineKickTime:i};a.forEach((function(e){var t=e.id,n=e.data;u.users[t]=n[0]||{}})),c({code:s.SUCCESS,data:u})}),(function(e){a._logger.error("joinRTCRoom error -> ".concat(e)),c({code:e})}),"","",u,p)}))},e.prototype.quitRTCRoom=function(e){var t=this;return new Promise((function(n){t._callCppProxy("exitRTCRoom",e,(function(){n(s.SUCCESS)}),n)}))},e.prototype.rtcPing=function(e,t,n){var o=this;return new Promise((function(t){o._callCppProxy("sendRTCPing",e,(function(){t(s.SUCCESS)}),t)}))},e.prototype.getRTCRoomInfo=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCResouce",e,2,(function(e){n({code:s.SUCCESS,data:JSON.parse(e)})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfoList=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getRTCResouce",e,1,(function(e){var t=JSON.parse(e).list,o={users:{}};t.forEach((function(e){var t=e.id,n=e.data;o.users[t]=n[0]||{}})),n({code:s.SUCCESS,data:o})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfo=function(e){throw new Error("Method not implemented.")},e.prototype.setRTCUserInfo=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("setRTCInnerData",e,m.PERSON,t,n,"","",(function(){r(s.SUCCESS)}),r)}))},e.prototype.removeRTCUserInfo=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("deleteRTCInnerData",e,m.PERSON,t,"","",(function(){o(s.SUCCESS)}),o)}))},e.prototype.setRTCData=function(e,t,n,o,r,i){var a=this;return new Promise((function(c){var u={room_innder:function(e,t,n,o,r,i,s){a._callCppProxy("setRTCInnerData",e,m.ROOM,t,n,o,r,i,s)},room_outer:function(e,t,n,o,r,i,s){a._callCppProxy("setRTCOuterData",e,m.ROOM,t,n,o,r,i,s)},user_innder:function(e,t,n,o,r,i,s){a._callCppProxy("setRTCInnerData",e,m.PERSON,t,n,o,r,i,s)},user_outer:function(e,t,n,o,r,i,s){a._callCppProxy("setRTCOuterData",e,m.PERSON,t,n,o,r,i,s)}},p=m.PERSON===r?"user":"room",l=o?"inner":"outer",d=u["".concat(p,"_").concat(l)];if(d){var f=(null==i?void 0:i.content)?JSON.stringify(i.content):"",C=(null==i?void 0:i.name)||"";d(e,t,n,C,f,(function(){c(s.SUCCESS)}),(function(e){c(e)}))}}))},e.prototype.setRTCTotalRes=function(e,t,n,o,r){var i=this;return new Promise((function(a){var c=t.name,u=t.content;i._callCppProxy("setUserResource",e,c,u,o,n,r,(function(){return a(s.SUCCESS)}),a)}))},e.prototype.setRTCCDNUris=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("setRTCCDNUris",e,t,n,(function(){return r(s.SUCCESS)}))}))},e.prototype.getRTCData=function(e,t,n,o){var r=this;return new Promise((function(i){var a={room_inner:function(e,t,n,o){r._callCppProxy("getRTCInnerData",e,m.ROOM,t,n,o).getRTCInnerData()},room_outer:function(e,t,n,o){r._callCppProxy("getRTCOuterData",e,m.ROOM,t,n,o)}},c=m.PERSON===o?"user":"room",u=n?"inner":"outer",p=a["".concat(c,"_").concat(u)];p&&p(e,t,(function(e){var t=JSON.parse(e),n={};t.list.forEach((function(e){var t=Object.keys(e)[0],o=Object.values(e)[0];n[t]=o})),i({code:s.SUCCESS,data:n})}),(function(e){i({code:e})}))}))},e.prototype.removeRTCData=function(e,t,n,o,r){var i=this;return new Promise((function(a){i._callCppProxy;var c={room_inner:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCInnerData",e,m.ROOM,t,n,o,r,s)},room_outer:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCOuterData",e,m.ROOM,t,n,o,r,s)},user_inner:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCInnerData",e,m.PERSON,t,n,o,r,s)},user_outer:function(e,t,n,o,r,s){i._callCppProxy("deleteRTCOuterData",e,m.PERSON,t,n,o,r,s)}},u=m.PERSON===o?"user":"room",p=n?"inner":"outer",l=c["".concat(u,"_").concat(p)];if(l){var d=(null==r?void 0:r.content)?JSON.stringify(r.content):"",f=(null==r?void 0:r.name)||"";l(e,t,f,d,(function(){a(s.SUCCESS)}),(function(e){a(e)}))}}))},e.prototype.setRTCOutData=function(e,t,n,o){throw new Error("Method not implemented.")},e.prototype.getRTCOutData=function(e,t){throw new Error("Method not implemented.")},e.prototype.getRTCToken=function(e,t,n){var o=this;return new Promise((function(t){o._callCppProxy("getRTCToken",e,(function(e){t({code:s.SUCCESS,data:{rtcToken:e}})}),(function(e){t({code:e})}))}))},e.prototype.setRTCState=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setRTCUserState",e,t,(function(){o(s.SUCCESS)}),o)}))},e.prototype.getRTCUserList=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCUsers",e,1,(function(e){n({code:s.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteTag",e,(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:s.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("getTags");e._logger.info("getTagList -> ",o);var r=e._convertResultList(o,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:s.SUCCESS,data:r})}))},e.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){o({code:s.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,o){var r=this;return new Promise((function(i,a){var c=r._callCppProxy("getConversationsForTagByPage",e,t,n||20,o||"");r._logger.info("getConversationListByTag -> ",c);var u=r._convertResultList(c,(function(e){return A(A({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:s.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(o,r){var i=n._callCppProxy("getConversationUnreadCountForTag",e,t);n._logger.info("getUnreadCountByTag -> ",i),o({code:s.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var o=this;return new Promise((function(r,i){o._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){r({code:s.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._logger.info("getTagsForConversation -> ",r);var i=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:s.SUCCESS,data:i})}))},e.prototype.joinLivingRoomAsAudience=function(e,t,n){return J(this,void 0,void 0,(function(){var n=this;return k(this,(function(o){return[2,new Promise((function(o,r){n._cppProtocol.audienceJoinRoom(e,t,(function(e,t){j.info("joinLivingRoomAsAudience data:",e,t),o({data:{token:e,kvEntries:G(t)},code:s.SUCCESS})}),(function(e){o({code:e})}))}))]}))}))},e.prototype.quitLivingRoomAsAudience=function(e){var t=this;return new Promise((function(n,o){t._cppProtocol.audienceLeaveRoom(e,(function(){n(s.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.switchLivingRoomRole=function(e,t,n){var o=this;return void 0===n&&(n=P.AUDIO_AND_VIDEO),new Promise((function(r,i){o._cppProtocol.switchRole(e,n,t,"","",(function(e,t,n,o,i,a){j.info("switchLivingRoomRole data:",e,t,n,o,i);var c=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:Y(o),kvEntries:G(i),offlineKickTime:a};c.forEach((function(e){var t=e.id,n=e.data;u.users[t]=n[0]||{}})),r({code:s.SUCCESS,data:u})}),(function(e){r({code:e})}))}))},e.prototype.getRTCJoinedUserInfo=function(e){var t=this;return new Promise((function(e){t._callCppProxy("queryJoinedRoom",(function(n){t._logger.info("getRTCJoinedUserInfo -> ",n);var o=JSON.parse(n).list[0];e(o?{code:s.SUCCESS,data:[JSON.parse(o.obj)]}:{code:s.SUCCESS})}),(function(t){e({code:t})}))}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.requestRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteTimeout,p=e.inviteInfo;t._callCppProxy("livePKInvitation",r,a,i,p,c,u,(function(){n(s.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.cancelRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteInfo;t._callCppProxy("livePKCancel",r,a,i,u,c,(function(){n(s.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.responseRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.inviteUserId,a=e.inviteRoomId,c=e.inviteSessionId,u=e.content,p=e.key,l=e.value,d=e.agree?1:0;t._callCppProxy("livePKAnswer",r,d,i,a,c,u,p,l,(function(){n(s.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.endRoomPK=function(e){var t=this;return new Promise((function(n,o){var r=e.roomId,i=e.endRoomId,a=e.sessionId,c=e.content,u=e.keys;t._callCppProxy("livePKHangup",r,i,a,c,u,(function(){n(s.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,o){var r=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",r,i,(function(){n(s.SUCCESS)}),(function(e){n(e)}))}))},e}(),$=function(e){return function(e,t){return j.setLogLevel(null==t?void 0:t.logLevel),j.setLogStdout(null==t?void 0:t.logStdout),new Q(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(D,e)};export{$ as default};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),n=require("electron"),r=require("fs"),i=require("crypto"),s=process.versions.electron.replace(/\.\d+$/,""),a=t.resolve(__dirname,"binding","electron-v".concat(s,"-").concat(e.platform(),"-").concat(e.arch(),".node")),c=null;try{c=require(a)}catch(e){console.error("error ->",a,"\n",e)}var u=c,p=function(){return p=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},p.apply(this,arguments)};function d(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function l(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function C(e,t,o){if(o||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}var f,g=new o.Logger("RCMain"),v=null,S=function(){var t,o=Date.now(),n=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=n,i.createHash("md5").update(t).digest("hex")},h=function(e){if(v)return v;var o=t.resolve(e,"deviceId");return g.debug("deviceIdPath -> ".concat(o)),r.existsSync(o)?v=r.readFileSync(o).toString():(v=S(),g.debug("createDeviceId -> ".concat(v)),r.writeFileSync(o,v),v)},_=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,o){return f?(f.stop(),f):f=new e(t,o)},e.prototype.start=function(e){var t=this,o=this,n=function(){var r=t._isFirstPing?0:15e3;o._timerId=setTimeout((function(){o._isFirstPing=!1,g.debug("current lossCount: "+o._lossCount),o._hasPingRes?(e(),o._hasPingRes=!1,n()):o._lossCount<4?(o._lossCount++,e(),n()):o._reconnect()}),r)};n()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){g.debug("receive pong"),this._hasPingRes=e,this._lossCount=0},e}(),y=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,o,n,r){var i=JSON.stringify(n);g.info("MsgExpansion._setToProtocol ===>",e,t,o,i,r),this._cppProto.setMessageExtension(e,t,o,i,r)},e.prototype.setLocalFromReceiveMsg=function(e){g.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId,r=e.messageUId,i=e.expansion,s=e.sentTime,a={};for(var c in i)a[c]={v:"",ts:0},a[c].v=i[c],a[c].ts=s;this._setToProtocol(o,n,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){g.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId;e.messageUId;var r=e.content,i=e.sentTime,s=r,a=s.put,c=this._cppProto.getMessage(s.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(g.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var d in a){var l=p[d];l&&l.ts<i-this._setTime?(l.v=a[d],l.ts=i-this._setTime):(p[d]={v:"",ts:0},p[d].v=a[d],p[d].ts=i-this._setTime)}s.del&&s.del.forEach((function(e){delete p[e]})),this._setToProtocol(o,n,s.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}(),E=function(e){var t=[];return JSON.parse(e).list.forEach((function(e){t.push(JSON.parse(e.obj))})),t},m=function(e){return JSON.parse(e).list.map((function(e){return{key:Object.keys(e)[0],value:Object.values(e)[0]}}))},P=function(){function e(e,t,r){void 0===t&&(t=""),void 0===r&&(r=!1);var i=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=r,this._currentToken="",this._connectionStatus=o.ConnectionStatus.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=o.ConnectionStatus.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._version="5.3.0",this._logger={debug:this._superLog.bind(this,"debug",o.LogLevel.DEBUG),info:this._superLog.bind(this,"info",o.LogLevel.INFO),warn:this._superLog.bind(this,"warn",o.LogLevel.WARN),error:this._superLog.bind(this,"error",o.LogLevel.ERROR),fatal:this._superLog.bind(this,"fatal",o.LogLevel.FATAL)},this._senders={},n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return d(i,void 0,void 0,(function(){var r,i,s,a;return l(this,(function(c){switch(c.label){case 0:if((a=this._logger).debug.apply(a,C(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],n,!1)),"function"!=typeof(r=this[t]))return e.returnValue=o.ErrorCode.NOT_SUPPORT,[2];i=o.ErrorCode.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.call.apply(r,C([this],n,!1))];case 2:return i=c.sent(),[3,4];case 3:return s=c.sent(),this._logger.error("call main process method `".concat(t,"` failed.")),this._logger.error(s),[3,4];case 4:return e.returnValue=i,[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],s=3;s<arguments.length;s++)r[s-3]=arguments[s];return d(i,void 0,void 0,(function(){var i,s,a,c,u,p=this;return l(this,(function(d){switch(d.label){case 0:if((u=this._logger).debug.apply(u,C(["__RC_CHANNEL_CALL_MAIN__",t,n],r,!1)),"function"!=typeof(i=this[n]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===n&&(s=r.pop(),r.push((function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}))),a=o.ErrorCode.EXTRA_METHOD_UNDEFINED,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,i.call.apply(i,C([this],r,!1))];case 2:return a=d.sent(),[3,4];case 3:return c=d.sent(),this._logger.error("call main process method `".concat(n,"` failed.")),this._logger.error(c),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];(o=i._logger).debug.apply(o,C(["__RC_CHANNEL_CALL_MAIN__",t],n,!1));var s=i[t];if("function"==typeof s)try{s.call.apply(s,C([i],n,!1))}catch(e){i._logger.error("call main process method `".concat(t,"` failed.")),i._logger.error(e)}else i._logger.error("cannot not found method: ".concat(t))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new y(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,o,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,n)}catch(t){(o=this._logger).error.apply(o,C([t,e],n,!1))}},e.prototype._superLog=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(g[e]&&g[e].apply(g,n),t!==o.LogLevel.DEBUG){var i=Object.keys(this._senders);if(i.length>0){var s=n.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[i[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,s,"RCMain")}}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(t=this._logger).info.apply(t,C(["callExtra -> ".concat(e)],n,!1));var i=this[e];if(!i)return this._logger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:o.ErrorCode.EXTRA_METHOD_UNDEFINED});try{return i.call.apply(i,C([this],n,!1))}catch(e){this._logger.error(e)}return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,n,r){var i,s=this,a=this._callCppProxy("getConversationListByPage",e,t,n,r||"");try{i=JSON.parse(a).list.map((function(e){return s._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:i})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],r=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(r).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,r=this,i=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],s=this._callCppProxy("getConversationListWithAllChannelByPage",i,e,t);try{n=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,r,i,s,a){var c=0===s,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,i,c,a||""),d=[];try{var l=JSON.parse(p).list;l.reverse();for(var C=0;C<l.length;C++){var f=this._buildMessage(l[C].obj);d[C]=f}}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===d.length?d.slice(1,u):d,hasMore:r<d.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,r){void 0===r&&(r=""),this._logger.info("updateMessageReceiptStatus ->",e,t,n,r);var i=this._callCppProxy("updateMessageReceiptStatus",e,t,n,r);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:i})},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this._naviInfo.userId},e.prototype._send2Renderer=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,C([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var n=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(r){var i=n._senders[r];o.includes(i)||n._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,o){var r=this,i=e.sender,s=i.id;if(this._senders[s]||(this._senders[s]=i,i.once("destroyed",(function(){delete r._senders[s]}))),!this._inited){this._inited=!0,this._initOptions=o,this._logger.info("init ->",o);var a=this._dbpath||t.resolve(n.app.getPath("userData"));this._callCppProxy("initWithAppkey",o.appkey,a),this._logger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var c=h(a);this._logger.info("deviceId -> ".concat(c)),this._callCppProxy("setDeviceId",c),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in o.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},o.SEND_MESSAGE_TYPE_OPTION){var t=o.SEND_MESSAGE_TYPE_OPTION[e],n=t.isCounted,r=0;t.isPersited&&(r|=1),n&&(r|=2),"RC:TypSts"===e&&(r=16),this._logger.info("_registerMsgTypes ====>",e,r),this._callCppProxy("registerMessageType",e,r)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,r=t.buildFrom,i=JSON.parse(e);this._logger.debug("_buildMessage:",i);var s=i.channelId,a=i.conversationType,c=i.targetId,u=i.senderUserId,d=i.content,l=i.objectName,C=i.messageUid,f=i.direction,v=i.status;i.source;var S=i.messageId,h=i.sentTime,_=i.readReceiptRequest,y=i.supportExt;i.extMsg;var E,m=i.pushContent,P=i.pushTitle,T=i.pushId,R=i.pushConfig,N=i.templateId,I=i.disableTitle,O=i.forcePushDetail;if(o.isObject(d))E=d;else try{E=d?JSON.parse(d):d}catch(e){g.warn("cpp engine build messaga error:",e),E=d}var M={isCounted:!1,isPersited:!1};l in o.SEND_MESSAGE_TYPE_OPTION?M=o.SEND_MESSAGE_TYPE_OPTION[l]:l in this._customMessageType&&(M=this._customMessageType[l]);var U=null;y&&(U=this._msgExpansionHandler.parseReceiveExpansion(i),"conversation"!==r&&"history"!==r||(U=this._msgExpansionHandler.parseConverOrHisExpansion(i)));var x=o.isUndefined(n)?h<this._connectedTime:n,b={};R&&(b=o.pushJSONToConfigs(R,T));var w=p(p({},b),{pushTitle:P,pushContent:m,pushData:m,disablePushTitle:I,forceShowDetailContent:O,templateId:N}),L={channelId:s,conversationType:a,targetId:c,senderUserId:u,content:E||{},messageType:l,messageUId:C,messageDirection:f,isOffLineMessage:x,sentTime:h,receivedTime:0,isPersited:M.isPersited,isCounted:M.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?U:null,receivedStatus:v,messageId:S,pushConfig:w};if(f===o.MessageDirection.RECEIVE?L.receivedStatus=v:f===o.MessageDirection.SEND&&(L.sentStatus=v),_){var A=JSON.parse(_),D=A.hasRespond,J=A.readerInfo,k={hasRespond:D,readCount:A.readCount,totalCount:A.totalCount},F=[];if(J)for(var H in J)F.push({userId:H,readTime:J[H]});k.readerList=F,L.readReceiptInfo=k}return L},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},i=p(p({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._logger.debug("_buildConversation",t);var n=t.channelId,r=t.conversationType,i=t.targetId,s=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,d=u?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:n,conversationType:r,targetId:i,unreadMessageCount:s,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:!1,mentionedInfo:null,notificationStatus:d,isTop:c,lastUnreadTime:0,matchCount:p}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n;switch(e._logger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:n=o.ConnectionStatus.CONNECTING;break;case 31004:return void setTimeout((function(){e._promiseHandler.connect&&e._promiseHandler.connect.resolve(o.ErrorCode.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:n=o.ConnectionStatus.DISCONNECTED;break;case 13:n=o.ConnectionStatus.BLOCKED;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:n=o.ConnectionStatus.NETWORK_UNAVAILABLE;break;case 30010:n=o.ConnectionStatus.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===o.ConnectionStatus.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:n=o.ConnectionStatus.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._promiseHandler.connect&&e._promiseHandler.connect.resolve(o.ErrorCode.SUCCESS),e._heartbeat=_.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:n=o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:n=o.ConnectionStatus.REDIRECT;break;default:n=t}n!==o.ConnectionStatus.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=n,e._sendConnectionStatus2Renderer(n)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;g.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(o.ConnectionStatus.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){g.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){g.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,r,i){var s=e._buildMessage(t,{isOffLineMessage:r});if(s.messageType===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var a=s.content,c=a.msgId,u=a.rrn,p=a.tmn;e._updateReadReceiptInfo(c,{readCount:u,totalCount:p})}if("RC:MsgExMsg"===s.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(s),void e._sendMessageExpansion(s);if(s.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(s),s.messageType===o.MessageType.SYNC_READ_STATUS){if(s.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",s.conversationType,s.targetId,s.content.lastMessageSendTime,s.channelId||"")}var d=!0;if(0!==n||i||(d=!1),s.messageType!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==s.senderUserId){var l=s.conversationType,C=s.targetId;s.messageType===o.MessageType.RECALL&&s.senderUserId===e._currentUserId&&(l=s.content.conversationType||l,C=s.content.targetId||C),e._sendMessageNotification(Object.assign(s,{hasMoreMsg:d,conversationType:l,targetId:C}))}else{var f=Object.keys(e._senders).map((function(t){return e._senders[t]}));f.length>0&&e._sendMessageNotification(Object.assign(s,{hasMoreMsg:d}),f.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,n=e.content,r=n.put,i=n.del,s=n.mid,a={};r&&(a.updatedExpansion={channelId:o,messageUId:s,expansion:r}),i&&(a.deletedExpansion={channelId:o,messageUId:s,deletedKeys:i}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,r=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,i=t.targetId,s=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};s.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),r.push({channelId:a,conversationType:n,targetId:i,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",r)}),(function(t){e._logger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._logger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){g.info("RTC Room Data Change:",t);var o=JSON.parse(t).list.map((function(e){var t=JSON.parse(e.obj);return{key:t.key,value:t.value,uid:t.operator,timestamp:t.version,status:t.isDeleted?1:0,roomId:t.roomId||""}}));e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,o,n){var r=0;t&&(r|=1),o&&(r|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this._callCppProxy("registerMessageType",e,r,n)},e.prototype.connect=function(e,t,n){var r=this;return this._logger.info("connect ->",e,t,n),this._currentToken===e&&this._connectionStatus===o.ConnectionStatus.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(o.ErrorCode.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,this._doConnect(n),new Promise((function(e,t){r._promiseHandler.connect={resolve:e,reject:t}})))},e.prototype._doConnect=function(e){var t=o.isUndefined(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._logger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop()},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("subscribeUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("setUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getUserStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,r){var i=this,s=n.messageType,a=n.content,c=n.pushContent,u=n.pushData,p=n.directionalUserIdList,d=n.disableNotification,l=n.canIncludeExpansion,C=n.expansion,f=n.isVoipPush,g=n.pushConfig,v=n.channelId,S=n.isMentioned,h=n.mentionedType,_=n.mentionedUserIdList,y=g||{},E=y.iOSConfig,m=y.androidConfig,P=y.pushTitle,T=y.pushContent,R=y.pushData,N=y.disablePushTitle,I=y.forceShowDetailContent,O=y.templateId,M=o.pushConfigsToJSON(E,m);return new Promise((function(n){c=T||c||"",u=R||u||"",d=d||!1,f=f||!1,P=P||"",T=T||"",R=R||"",N=N||!1,I=I||!1,l=l||!1;var g=(null==m?void 0:m.notificationId)||"";if(p=p||[],v=v||"",e===o.ConversationType.GROUP&&S&&a&&(a.mentionedInfo={userIdList:_,type:h||o.MentionedType.ALL}),e===o.ConversationType.GROUP&&s===o.MessageType.READ_RECEIPT_RESPONSE&&a.receiptMessageDic)for(var y in a.receiptMessageDic)p.push(y);var E={};for(var y in C)E[y]={v:""},E[y].v=C[y];var U=O||"",x=i._callCppProxy("sendMessage",(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return t===o.ErrorCode.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===r.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(r),r.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(r),n({code:o.ErrorCode.SUCCESS,data:r}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,s,JSON.stringify(a),p,d,N,I,c,u,g,P,M,U,l,JSON.stringify(E),f,v),b=JSON.parse(x);r&&r(b.messageId)}))},e.prototype.recallMsg=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){var u,p=i.user,d=i.pushContent,l=i.channelId,C=i.extra,f=i.pushConfig,g=i.disableNotification,v={conversationType:e,targetId:t,messageUId:n,sentTime:r,user:p,extra:C,channelId:l};p&&(v.user=p),C&&(v.extra=C);var S={conversationType:e,targetId:t,senderUserId:s._currentUserId,content:v,objectName:o.MessageType.RECALL,messageUid:n,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:r,channelId:l},h=s._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){a({code:o.ErrorCode.SUCCESS,data:h})}),(function(e){a({code:e})}),o.MessageType.RECALL,JSON.stringify(v),g||!1,(null==f?void 0:f.disablePushTitle)||!1,(null==f?void 0:f.forceShowDetailContent)||!1,d||"",(null==f?void 0:f.pushData)||"",(null===(u=null==f?void 0:f.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==f?void 0:f.pushTitle)||"",o.pushConfigsToJSON(null==f?void 0:f.iOSConfig,null==f?void 0:f.androidConfig),(null==f?void 0:f.templateId)||"",l)}))},e.prototype.getHistoryMessage=function(e,t,n,r,i,s,a){var c=this;return new Promise((function(u,p){n=n||0;var d=0===i,l=r+1,C=c._callCppProxy("getHistoryMessages",e,t,n,l,a,d,s),f=JSON.parse(C).list,g=[];f.reverse();for(var v=0;v<f.length;v++){var S=c._buildMessage(f[v].obj);g[v]=S}u({code:o.ErrorCode.SUCCESS,data:{list:l===g.length?g.slice(1,l):g,hasMore:r<g.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,r,i,s){var a=this;return new Promise((function(c,u){n=n||0;a._callCppProxy("getRemoteHistoryMessages",e,t,n,r,(function(e,t){var n=JSON.parse(e).list,r=[];n.reverse();for(var i=0;i<n.length;i++){var s=a._buildMessage(n[i].obj);r[i]=s}c({code:o.ErrorCode.SUCCESS,data:{list:r,hasMore:!!t}})}),(function(e){c({code:e})}),i,!0,s)}))},e.prototype.deleteRemoteMessage=function(e,t,n,r){var i=this;return new Promise((function(s,a){var c=JSON.stringify(n);i._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,r,(function(){s(o.ErrorCode.SUCCESS)}),s)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(o.ErrorCode.SUCCESS)}),(function(e){s(e)}),r)}))},e.prototype.clearMessages=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("clearMessages",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,r,i){var s=this;return void 0===i&&(i=""),new Promise((function(e,t){for(var n=s._callCppProxy("getConversationList",[1,3,6,7],i),r=JSON.parse(n).list,a=[],c=0;c<r.length;c++)a.push(s._buildConversation(r[c].obj));e({code:o.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getConversation",e,t,n);if(a)i({code:o.ErrorCode.SUCCESS,data:r._buildConversation(a)});else{var c=r._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){r._logger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=r._buildMessage(u[0].obj));var d=r._callCppProxy("getConversationNotificationStatus",e,t,n),l=r._callCppProxy("getConversationTopStatus",e,t,n);i({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:d?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(l),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var r=this._callCppProxy("removeConversation",e,t,n);return this._logger.info("removeConversation result -> ".concat(r)),Promise.resolve(r?o.ErrorCode.SUCCESS:o.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(r,i){var s=[];s=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],n._callCppProxy("clearConversations",s,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var r=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(i){var s=r._callCppProxy("getUnreadCount",e,t,n);i({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(i,s){r._callCppProxy("clearUnreadCount",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("clearUnreadCountByTimestamp",e,t,n,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=r._buildMessage(a);i({code:o.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,r){var i=this;return void 0===r&&(r=""),new Promise((function(s,a){i._logger.info("setConversationToTop",e,t,n,r,true),i._callCppProxy("setConversationToTop",e,t,n,r,true),s(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("setConversationHidden",e,t,n,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._logger.info("setConversationNotificationStatus",e,t,n,r),i._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(o.ErrorCode.SUCCESS)}),s,r)}))},e.prototype.setConversationStatus=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){s._logger.info("setConversationStatus",e,t,n,r,i,true),s._callCppProxy("setConversationStatus",e,t,n,r,(function(){a(o.ErrorCode.SUCCESS)}),a,i,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getConversationNotificationStatus",e,t,n);i({code:o.ErrorCode.SUCCESS,data:a?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,r){var i=this;return new Promise((function(s,a){r=r||[1,3,6,7];for(var c=i._callCppProxy("searchConversationByContent",r,e,t,n),u=JSON.parse(c).list,p=[],d=0;d<u.length;d++)p[d]=i._buildConversation(u[d].obj);s({code:o.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchMessageByContent=function(e,t,n,r,i,s,a){var c=this;return new Promise((function(s,u){c._callCppProxy("searchMessageByContent",e,t,n,r,i,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],i=0;i<n.length;i++)r[i]=c._buildMessage(n[i].obj);s({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}),a)}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addToBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("removeFromBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var r=this,i=n.content,s=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,d=n.sentTime,l=n.searchContent,C=n.isUnread,f=n.messageUId,g=n.disableNotification,v=n.canIncludeExpansion,S=n.expansionMsg,h=n.channelId;return i=JSON.stringify(i),new Promise((function(n,_){var y=C?0:1,E=r._callCppProxy("insertMessage",e,t,s,a,i,(function(){}),(function(e){n({code:e})}),c,u,p,d,l,y,f,g,v,S,h);r._logger.info("after insert msg",E);var m=r._buildMessage(E,{isOffLineMessage:!1});m.messageUId=f,m.sentTime=d,n({code:-1===m.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:m})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteMessages",e),n(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,r,i),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,r){var i=t._callCppProxy("getMessage",e);t._logger.info("getMessage ===>",i);var s=t._buildMessage(i,{isOffLineMessage:!1});n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setMessageContent=function(e,t,n){var r=this;return new Promise((function(i,s){t=JSON.stringify(t),r._callCppProxy("setMessageContent",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setMessageSearchField",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("setMessageSentStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("setMessageReceivedStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,r=t.targetId,i=t.isTop,s=t.notificationStatus,a=t.channelId;if(void 0!==i&&void 0===s)return this.setConversationToTop(n,r,i,a);if(void 0!==s&&void 0===i){var c=s===o.NotificationStatus.OPEN;return this.setConversationNotificationStatus(n,r,c,a)}c=s===o.NotificationStatus.OPEN;return this.setConversationStatus(n,r,c,i,a)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){r._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(r._callCppProxy("getMessage",e)).messageId;r.setMessageReceivedStatus(t,1)}catch(t){r._logger.warn("format message error, messageUId: "+e)}})),i({code:o.ErrorCode.SUCCESS})}),(function(e){i({code:e})}))}))},e.prototype.getMessageReader=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("getMessageReader",e,n,t,(function(e,n){r._logger.info("getMessageReader -> ",e,n);var s=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;s.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:s.length,totalCount:n};r._updateReadReceiptInfo(t,c),i({code:o.ErrorCode.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){i({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("quitChatRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],r=[];if(n.length>0)for(var s=0;s<n.length;s++)r.push(JSON.parse(n[s].obj));i({code:o.ErrorCode.SUCCESS,data:{userInfos:r,userCount:t}})}),(function(e){i({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("getChatroomHistoryMessage",e,t,n,r,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return i._buildMessage(e.obj)}))}catch(e){t.list=[]}s({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(r,i){var s='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';n._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,r=[t.key];return new Promise((function(i,s){n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(r){var i=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,i,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return d(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=r.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,r){var i=this;return n=n||"",r=r||"",new Promise((function(s){var a;a=r&&"uploads"!==r?t||"":o.getUploadFileName(e,t),i._callCppProxy("getUploadToken",e,a,n,r,(function(e,t,n,r,i,c,u,p,d,l,C,f,g,v,S,h,_,y){s({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:r,osskeyId:i,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:d,s3Algorithm:l,s3Date:C,s3Policy:f,s3Signature:g,s3BucketName:v,stcAuthorization:S,stcContentSha256:h,stcDate:_,stcBucketName:y}})}),(function(e){s({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,r){var i=this;return new Promise((function(s){i._callCppProxy("getDownloadUrl",e,n,r,t-1,(function(e){s({code:o.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return h(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("getVoIPKey",e,t,"",(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.joinRTCRoom=function(e,t,n,r,i,s){var a=this;return new Promise((function(c){var u=i?JSON.stringify(i):"",p=s?JSON.stringify(s):"";a._callCppProxy("joinRTCRoom",e,t,n||0,r||o.RTCJoinType.KICK,(function(e,t,n,r){var i=JSON.parse(e).list,s={token:t,sessionId:n,users:{},roomInfo:m(r),kvEntries:[]};i.forEach((function(e){var t=e.id,o=e.data;s.users[t]=o[0]||{}})),c({code:o.ErrorCode.SUCCESS,data:s})}),(function(e){a._logger.error("joinRTCRoom error -> ".concat(e)),c({code:e})}),"","",u,p)}))},e.prototype.quitRTCRoom=function(e){var t=this;return new Promise((function(n){t._callCppProxy("exitRTCRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.rtcPing=function(e,t,n){var r=this;return new Promise((function(t){r._callCppProxy("sendRTCPing",e,(function(){t(o.ErrorCode.SUCCESS)}),t)}))},e.prototype.getRTCRoomInfo=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCResouce",e,2,(function(e){n({code:o.ErrorCode.SUCCESS,data:JSON.parse(e)})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfoList=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getRTCResouce",e,1,(function(e){var t=JSON.parse(e).list,r={users:{}};t.forEach((function(e){var t=e.id,o=e.data;r.users[t]=o[0]||{}})),n({code:o.ErrorCode.SUCCESS,data:r})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfo=function(e){throw new Error("Method not implemented.")},e.prototype.setRTCUserInfo=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setRTCInnerData",e,o.RTCApiType.PERSON,t,n,"","",(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.removeRTCUserInfo=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.PERSON,t,"","",(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.setRTCData=function(e,t,n,r,i,s){var a=this;return new Promise((function(c){var u={room_innder:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCInnerData",e,o.RTCApiType.ROOM,t,n,r,i,s,c)},room_outer:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCOuterData",e,o.RTCApiType.ROOM,t,n,r,i,s,c)},user_innder:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCInnerData",e,o.RTCApiType.PERSON,t,n,r,i,s,c)},user_outer:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCOuterData",e,o.RTCApiType.PERSON,t,n,r,i,s,c)}},p=o.RTCApiType.PERSON===i?"user":"room",d=r?"inner":"outer",l=u["".concat(p,"_").concat(d)];if(l){var C=(null==s?void 0:s.content)?JSON.stringify(s.content):"",f=(null==s?void 0:s.name)||"";l(e,t,n,f,C,(function(){c(o.ErrorCode.SUCCESS)}),(function(e){c(e)}))}}))},e.prototype.setRTCTotalRes=function(e,t,n,r,i){var s=this;return new Promise((function(a){var c=t.name,u=t.content;s._callCppProxy("setUserResource",e,c,u,r,n,i,(function(){return a(o.ErrorCode.SUCCESS)}),a)}))},e.prototype.setRTCCDNUris=function(e,t,n){var r=this;return new Promise((function(i){r._callCppProxy("setRTCCDNUris",e,t,n,(function(){return i(o.ErrorCode.SUCCESS)}))}))},e.prototype.getRTCData=function(e,t,n,r){var i=this;return new Promise((function(s){var a={room_inner:function(e,t,n,r){i._callCppProxy("getRTCInnerData",e,o.RTCApiType.ROOM,t,n,r).getRTCInnerData()},room_outer:function(e,t,n,r){i._callCppProxy("getRTCOuterData",e,o.RTCApiType.ROOM,t,n,r)}},c=o.RTCApiType.PERSON===r?"user":"room",u=n?"inner":"outer",p=a["".concat(c,"_").concat(u)];p&&p(e,t,(function(e){var t=JSON.parse(e),n={};t.list.forEach((function(e){var t=Object.keys(e)[0],o=Object.values(e)[0];n[t]=o})),s({code:o.ErrorCode.SUCCESS,data:n})}),(function(e){s({code:e})}))}))},e.prototype.removeRTCData=function(e,t,n,r,i){var s=this;return new Promise((function(a){s._callCppProxy;var c={room_inner:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.ROOM,t,n,r,i,a)},room_outer:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCOuterData",e,o.RTCApiType.ROOM,t,n,r,i,a)},user_inner:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.PERSON,t,n,r,i,a)},user_outer:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCOuterData",e,o.RTCApiType.PERSON,t,n,r,i,a)}},u=o.RTCApiType.PERSON===r?"user":"room",p=n?"inner":"outer",d=c["".concat(u,"_").concat(p)];if(d){var l=(null==i?void 0:i.content)?JSON.stringify(i.content):"",C=(null==i?void 0:i.name)||"";d(e,t,C,l,(function(){a(o.ErrorCode.SUCCESS)}),(function(e){a(e)}))}}))},e.prototype.setRTCOutData=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getRTCOutData=function(e,t){throw new Error("Method not implemented.")},e.prototype.getRTCToken=function(e,t,n){var r=this;return new Promise((function(t){r._callCppProxy("getRTCToken",e,(function(e){t({code:o.ErrorCode.SUCCESS,data:{rtcToken:e}})}),(function(e){t({code:e})}))}))},e.prototype.setRTCState=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setRTCUserState",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getRTCUserList=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCUsers",e,1,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteTag",e,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("getTags");e._logger.info("getTagList -> ",r);var i=e._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(r,i){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(r,i){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,r){var i=this;return new Promise((function(s,a){var c=i._callCppProxy("getConversationsForTagByPage",e,t,n||20,r||"");i._logger.info("getConversationListByTag -> ",c);var u=i._convertResultList(c,(function(e){return p(p({},i._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(r,i){var s=n._callCppProxy("getConversationUnreadCountForTag",e,t);n._logger.info("getUnreadCountByTag -> ",s),r({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){i({code:o.ErrorCode.SUCCESS})}),(function(e){i({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,r){var i=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._logger.info("getTagsForConversation -> ",i);var s=t._convertResultList(i,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.joinLivingRoomAsAudience=function(e,t,n){return d(this,void 0,void 0,(function(){var n=this;return l(this,(function(r){return[2,new Promise((function(r,i){n._cppProtocol.audienceJoinRoom(e,t,(function(e,t){g.info("joinLivingRoomAsAudience data:",e,t),r({data:{token:e,kvEntries:E(t)},code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))]}))}))},e.prototype.quitLivingRoomAsAudience=function(e){var t=this;return new Promise((function(n,r){t._cppProtocol.audienceLeaveRoom(e,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.switchLivingRoomRole=function(e,t,n){var r=this;return void 0===n&&(n=o.LiveType.AUDIO_AND_VIDEO),new Promise((function(i,s){r._cppProtocol.switchRole(e,n,t,"","",(function(e,t,n,r,s){g.info("switchLivingRoomRole data:",e,t,n,r,s);var a=JSON.parse(e).list,c={token:t,sessionId:n,users:{},roomInfo:m(r),kvEntries:E(s)};a.forEach((function(e){var t=e.id,o=e.data;c.users[t]=o[0]||{}})),i({code:o.ErrorCode.SUCCESS,data:c})}),(function(e){i({code:e})}))}))},e.prototype.getRTCJoinedUserInfo=function(e){var t=this;return new Promise((function(e){t._callCppProxy("queryJoinedRoom",(function(n){t._logger.info("getRTCJoinedUserInfo -> ",n);var r=JSON.parse(n).list[0];e(r?{code:o.ErrorCode.SUCCESS,data:[JSON.parse(r.obj)]}:{code:o.ErrorCode.SUCCESS})}),(function(t){e({code:t})}))}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.requestRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteTimeout,p=e.inviteInfo;t._callCppProxy("livePKInvitation",i,a,s,p,c,u,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.cancelRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteInfo;t._callCppProxy("livePKCancel",i,a,s,u,c,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.responseRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.inviteUserId,a=e.inviteRoomId,c=e.inviteSessionId,u=e.content,p=e.key,d=e.value,l=e.agree?1:0;t._callCppProxy("livePKAnswer",i,l,s,a,c,u,p,d,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.endRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.endRoomId,a=e.sessionId,c=e.content,u=e.keys;t._callCppProxy("livePKHangup",i,s,a,c,u,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,r){var i=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",i,s,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e}();module.exports=function(e){return function(e,t){return g.setLogLevel(null==t?void 0:t.logLevel),g.setLogStdout(null==t?void 0:t.logStdout),new P(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(u,e)};
|
|
1
|
+
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),n=require("electron"),r=require("fs"),i=require("crypto"),s=require("http"),a=require("https"),c=process.versions.electron.replace(/\.\d+$/,""),u=t.resolve(__dirname,"binding","electron-v".concat(c,"-").concat(e.platform(),"-").concat(e.arch(),".node")),p=null;try{p=require(u)}catch(e){console.error("error ->",u,"\n",e)}var l=p,d=function(){return d=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},d.apply(this,arguments)};function C(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function f(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function v(e,t,o){if(o||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}var g,h=new o.Logger("RCMain"),S=null,_=function(){var t,o=Date.now(),n=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=n,i.createHash("md5").update(t).digest("hex")},y=function(e){if(S)return S;var o=t.resolve(e,"deviceId");return h.debug("deviceIdPath -> ".concat(o)),r.existsSync(o)?S=r.readFileSync(o).toString():(S=_(),h.debug("createDeviceId -> ".concat(S)),r.writeFileSync(o,S),S)},E=function(){function e(e,t){this._timerId=0,this._heartbeatTimeoutId=0,this._isFirstPing=!0,this._lossCount=0,this._hasPingRes=e,this._reconnect=t}return e.init=function(t,o){return g?(g.stop(),g):g=new e(t,o)},e.prototype.start=function(e){var t=this,o=this,n=function(){var r=t._isFirstPing?0:15e3;o._timerId=setTimeout((function(){o._isFirstPing=!1,h.debug("current lossCount: "+o._lossCount),o._hasPingRes?(e(),o._hasPingRes=!1,n()):o._lossCount<4?(o._lossCount++,e(),n()):o._reconnect()}),r)};n()},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(e){h.debug("receive pong"),this._hasPingRes=e,this._lossCount=0},e}(),m=function(){function e(e){this._setTime=15962112e5,this._cppProto=e}return e.prototype._setToProtocol=function(e,t,o,n,r){var i=JSON.stringify(n);h.info("MsgExpansion._setToProtocol ===>",e,t,o,i,r),this._cppProto.setMessageExtension(e,t,o,i,r)},e.prototype.setLocalFromReceiveMsg=function(e){h.info("MsgExpansion.setLocalFromReceiveMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId,r=e.messageUId,i=e.expansion,s=e.sentTime,a={};for(var c in i)a[c]={v:"",ts:0},a[c].v=i[c],a[c].ts=s;this._setToProtocol(o,n,r,a,t||"")},e.prototype.setLocalFromExtMsg=function(e){h.info("MsgExpansion.setLocalFromExtMsg ===>",e);var t=e.channelId,o=e.conversationType,n=e.targetId;e.messageUId;var r=e.content,i=e.sentTime,s=r,a=s.put,c=this._cppProto.getMessage(s.mid),u=JSON.parse(c).extMsg,p=JSON.parse(u||"{}");if(h.info("MsgExpansion.setLocalFromExtMsg, serverExtObj",a,"localExt",p),a)for(var l in a){var d=p[l];d&&d.ts<i-this._setTime?(d.v=a[l],d.ts=i-this._setTime):(p[l]={v:"",ts:0},p[l].v=a[l],p[l].ts=i-this._setTime)}s.del&&s.del.forEach((function(e){delete p[e]})),this._setToProtocol(o,n,s.mid,p,t||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}(),P=function(e){var t=[];return JSON.parse(e).list.forEach((function(e){t.push(JSON.parse(e.obj))})),t},T=function(e){return JSON.parse(e).list.map((function(e){return{key:Object.keys(e)[0],value:Object.values(e)[0]}}))},R=null;function I(e,t,o,n,r){return void 0===r&&(r=!0),C(this,void 0,void 0,(function(){var i;return f(this,(function(c){switch(c.label){case 0:return R?[2,R]:(R=function(e,t,o,n,r){return void 0===r&&(r=!0),C(this,void 0,void 0,(function(){var i,c,u,p;return f(this,(function(l){switch(l.label){case 0:i=function(i,c){var u,p,l,d,C;return f(this,(function(c){switch(c.label){case 0:return u="".concat(t[i],"/navi.json?r=").concat(Date.now()),p="token=".concat(encodeURIComponent(n),"&v=").concat((f=e,f.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.3.3"),h.info("request navi -> url: ".concat(u,", body: ").concat(p)),[4,new Promise((function(e){var t=/^https/.test(u),n={headers:{appId:o},method:"POST"};t&&(n.rejectUnauthorized=r,n.agent=new a.Agent(n));var i=(t?a.request:s.request)(u,n,(function(t){var o=t.statusCode,n="";t.setEncoding("utf8"),t.on("data",(function(e){n+=e})),t.on("end",(function(){e({status:o||0,data:n})}))}));i.on("error",(function(t){h.error(t),e({status:0})})),i.write(p),i.end()}))];case 1:if(200!==(l=c.sent()).status)return h.error("request navi failed -> ".concat(u)),l.data&&h.error(l.data),[2,"continue"];h.info("request navi success -> ".concat(u));try{return d=JSON.parse(l.data),C=/^https/.test(u)?"https":"http",d.protocol=C,[2,{value:d}]}catch(e){h.error("parse navi err => ".concat(l.data))}return[2]}var f}))},c=0,u=t.length,l.label=1;case 1:return c<u?[5,i(c,u)]:[3,4];case 2:if("object"==typeof(p=l.sent()))return[2,p.value];l.label=3;case 3:return c+=1,[3,1];case 4:return[2,null]}}))}))}(e,t,o,n,r),[4,R]);case 1:return i=c.sent(),R=null,[2,i]}}))}))}var N=function(){function e(e,t,r){void 0===t&&(t=""),void 0===r&&(r=!1);var i=this;this._cppProtocol=e,this._dbpath=t,this._reconnectKickEnable=r,this._currentToken="",this._connectionStatus=o.ConnectionStatus.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._heartbeat={},this._cppConnectionStatus=o.ConnectionStatus.DISCONNECTED,this._connectedTime=0,this._currentUserId="",this._inited=!1,this._version="5.3.3",this.naviInfo=null,this._logger={debug:this._superLog.bind(this,"debug",o.LogLevel.DEBUG),info:this._superLog.bind(this,"info",o.LogLevel.INFO),warn:this._superLog.bind(this,"warn",o.LogLevel.WARN),error:this._superLog.bind(this,"error",o.LogLevel.ERROR),fatal:this._superLog.bind(this,"fatal",o.LogLevel.FATAL)},this._senders={},n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return C(i,void 0,void 0,(function(){var r,i,s,a;return f(this,(function(c){switch(c.label){case 0:if((a=this._logger).debug.apply(a,v(["__RC_CHANNEL_CALL_MAIN_SYNC__",t],n,!1)),"function"!=typeof(r=this[t]))return e.returnValue=o.ErrorCode.NOT_SUPPORT,[2];i=o.ErrorCode.EXTRA_METHOD_UNDEFINED,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.call.apply(r,v([this],n,!1))];case 2:return i=c.sent(),[3,4];case 3:return s=c.sent(),this._logger.error("call main process method `".concat(t,"` failed.")),this._logger.error(s),[3,4];case 4:return e.returnValue=i,[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],s=3;s<arguments.length;s++)r[s-3]=arguments[s];return C(i,void 0,void 0,(function(){var i,s,a,c,u,p=this;return f(this,(function(l){switch(l.label){case 0:if((u=this._logger).debug.apply(u,v(["__RC_CHANNEL_CALL_MAIN__",t,n],r,!1)),"function"!=typeof(i=this[n]))return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===n&&(s=r.pop(),r.push((function(t){p._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}))),a=o.ErrorCode.EXTRA_METHOD_UNDEFINED,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,i.call.apply(i,v([this],r,!1))];case 2:return a=l.sent(),[3,4];case 3:return c=l.sent(),this._logger.error("call main process method `".concat(n,"` failed.")),this._logger.error(c),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];(o=i._logger).debug.apply(o,v(["__RC_CHANNEL_CALL_MAIN__",t],n,!1));var s=i[t];if("function"==typeof s)try{s.call.apply(s,v([i],n,!1))}catch(e){i._logger.error("call main process method `".concat(t,"` failed.")),i._logger.error(e)}else i._logger.error("cannot not found method: ".concat(t))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._init.bind(this)),this._msgExpansionHandler=new m(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,o,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];try{return(t=this._cppProtocol)[e].apply(t,n)}catch(t){(o=this._logger).error.apply(o,v([t,e],n,!1))}},e.prototype._superLog=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(h[e]&&h[e].apply(h,n),t!==o.LogLevel.DEBUG){var i=Object.keys(this._senders);if(i.length>0){var s=n.reduce((function(e,t){return e+JSON.stringify(t)}),"");this._senders[i[0]].send("__RC_CHANNEL_CALL_RENDER__","_insertLog2IndexDB",t,s,"RCMain")}}},e.prototype.getCppProto=function(){return this._cppProtocol},e.prototype.callExtra=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(t=this._logger).info.apply(t,v(["callExtra -> ".concat(e)],n,!1));var i=this[e];if(!i)return this._logger.warn("ExtraHandler.".concat(e," is undefined")),Promise.resolve({code:o.ErrorCode.EXTRA_METHOD_UNDEFINED});try{return i.call.apply(i,v([this],n,!1))}catch(e){this._logger.error(e)}return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,n,r){var i,s=this,a=this._callCppProxy("getConversationListByPage",e,t,n,r||"");try{i=JSON.parse(a).list.map((function(e){return s._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:i})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],r=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(r).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,r=this,i=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],s=this._callCppProxy("getConversationListWithAllChannelByPage",i,e,t);try{n=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,r,i,s,a){var c=0===s,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,i,c,a||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var C=0;C<d.length;C++){var f=this._buildMessage(d[C].obj);l[C]=f}}catch(e){return this._logger.error(e),Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:r<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,r){void 0===r&&(r=""),this._logger.info("updateMessageReceiptStatus ->",e,t,n,r);var i=this._callCppProxy("updateMessageReceiptStatus",e,t,n,r);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:i})},e.prototype.requestNaviInfo=function(e,t,o,n){return C(this,void 0,void 0,(function(){return f(this,(function(r){return[2,I(this._initOptions.apiVersion,e,t,o,n)]}))}))},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this._naviInfo.userId},e.prototype._send2Renderer=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,v([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var n=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(r){var i=n._senders[r];o.includes(i)||n._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._init=function(e,o){var r=this,i=e.sender,s=i.id;if(this._senders[s]||(this._senders[s]=i,i.once("destroyed",(function(){delete r._senders[s]}))),!this._inited){this._inited=!0,this._initOptions=o,this._logger.info("init ->",o);var a=this._dbpath||t.resolve(n.app.getPath("userData"));this._callCppProxy("initWithAppkey",o.appkey,a),this._logger.warn("cppProto version ->",this._cppProtocol.getNodeVersion()),this._registerMsgTypes();var c=y(a);this._logger.info("deviceId -> ".concat(c)),this._callCppProxy("setDeviceId",c),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener()}},e.prototype._registerMsgTypes=function(){for(var e in o.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},o.SEND_MESSAGE_TYPE_OPTION){var t=o.SEND_MESSAGE_TYPE_OPTION[e],n=t.isCounted,r=0;t.isPersited&&(r|=1),n&&(r|=2),"RC:TypSts"===e&&(r=16),this._logger.info("_registerMsgTypes ====>",e,r),this._callCppProxy("registerMessageType",e,r)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,r=t.buildFrom,i=JSON.parse(e);this._logger.debug("_buildMessage:",i);var s=i.channelId,a=i.conversationType,c=i.targetId,u=i.senderUserId,p=i.content,l=i.objectName,C=i.messageUid,f=i.direction,v=i.status;i.source;var g=i.messageId,S=i.sentTime,_=i.readReceiptRequest,y=i.supportExt;i.extMsg;var E,m=i.pushContent,P=i.pushTitle,T=i.pushId,R=i.pushConfig,I=i.templateId,N=i.disableTitle,O=i.forcePushDetail;if(o.isObject(p))E=p;else try{E=p?JSON.parse(p):p}catch(e){h.warn("cpp engine build messaga error:",e),E=p}var M={isCounted:!1,isPersited:!1};l in o.SEND_MESSAGE_TYPE_OPTION?M=o.SEND_MESSAGE_TYPE_OPTION[l]:l in this._customMessageType&&(M=this._customMessageType[l]);var U=null;y&&(U=this._msgExpansionHandler.parseReceiveExpansion(i),"conversation"!==r&&"history"!==r||(U=this._msgExpansionHandler.parseConverOrHisExpansion(i)));var x=o.isUndefined(n)?S<this._connectedTime:n,b={};R&&(b=o.pushJSONToConfigs(R,T));var w=d(d({},b),{pushTitle:P,pushContent:m,pushData:m,disablePushTitle:N,forceShowDetailContent:O,templateId:I}),L={channelId:s,conversationType:a,targetId:c,senderUserId:u,content:E||{},messageType:l,messageUId:C,messageDirection:f,isOffLineMessage:x,sentTime:S,receivedTime:0,isPersited:M.isPersited,isCounted:M.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?U:null,receivedStatus:v,messageId:g,pushConfig:w};if(f===o.MessageDirection.RECEIVE?L.receivedStatus=v:f===o.MessageDirection.SEND&&(L.sentStatus=v),_){var A=JSON.parse(_),D=A.hasRespond,J=A.readerInfo,k={hasRespond:D,readCount:A.readCount,totalCount:A.totalCount},H=[];if(J)for(var F in J)H.push({userId:F,readTime:J[F]});k.readerList=H,L.readReceiptInfo=k}return L},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},i=d(d({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},e.prototype._buildConversation=function(e){var t=JSON.parse(e);this._logger.debug("_buildConversation",t);var n=t.channelId,r=t.conversationType,i=t.targetId,s=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,l=u?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:n,conversationType:r,targetId:i,unreadMessageCount:s,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:!1,mentionedInfo:null,notificationStatus:l,isTop:c,lastUnreadTime:0,matchCount:p}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n;switch(e._logger.warn("protocol connection status changed:",t),e._cppConnectionStatus=t,t){case 10:n=o.ConnectionStatus.CONNECTING;break;case 31004:return void setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_OR_PASSWD_ERROR)}));case 12:n=o.ConnectionStatus.DISCONNECTED;break;case 13:n=o.ConnectionStatus.BLOCKED;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:n=o.ConnectionStatus.NETWORK_UNAVAILABLE;break;case 30010:n=o.ConnectionStatus.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===o.ConnectionStatus.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:n=o.ConnectionStatus.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(o.ErrorCode.SUCCESS),e._heartbeat=E.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:n=o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 30004:return;case 8:case 31006:case 32061:case 32012:n=o.ConnectionStatus.REDIRECT;break;default:n=t}n!==o.ConnectionStatus.CONNECTED&&e._heartbeat&&e._heartbeat.stop&&e._heartbeat.stop(),e._connectionStatus=n,e._sendConnectionStatus2Renderer(n)}),this._dbOpenCallback,(function(){e._heartbeat.setHeartbeatRes(!0)}))},e.prototype._handleHeartTimeout=function(){var e=this;h.warn("network unavailable! try to reconnect!"),this._sendConnectionStatus2Renderer(o.ConnectionStatus.NETWORK_UNAVAILABLE),this._heartbeat.stop(),setTimeout((function(){return e._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){h.info("Sqlite DB Open -> ".concat(e))},e.prototype._sendHeartbeat=function(){h.debug("send ping"),this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,r,i){var s=e._buildMessage(t,{isOffLineMessage:r});if(s.messageType===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var a=s.content,c=a.msgId,u=a.rrn,p=a.tmn;e._updateReadReceiptInfo(c,{readCount:u,totalCount:p})}if("RC:MsgExMsg"===s.messageType)return e._msgExpansionHandler.setLocalFromExtMsg(s),void e._sendMessageExpansion(s);if(s.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(s),s.messageType===o.MessageType.SYNC_READ_STATUS){if(s.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",s.conversationType,s.targetId,s.content.lastMessageSendTime,s.channelId||"")}var l=!0;if(0!==n||i||(l=!1),s.messageType!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==s.senderUserId){var d=s.conversationType,C=s.targetId;s.messageType===o.MessageType.RECALL&&s.senderUserId===e._currentUserId&&(d=s.content.conversationType||d,C=s.content.targetId||C),e._sendMessageNotification(Object.assign(s,{hasMoreMsg:l,conversationType:d,targetId:C}))}else{var f=Object.keys(e._senders).map((function(t){return e._senders[t]}));f.length>0&&e._sendMessageNotification(Object.assign(s,{hasMoreMsg:l}),f.slice(1))}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,n=e.content,r=n.put,i=n.del,s=n.mid,a={};r&&(a.updatedExpansion={channelId:o,messageUId:s,expansion:r}),i&&(a.deletedExpansion={channelId:o,messageUId:s,deletedKeys:i}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,r=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,i=t.targetId,s=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};s.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),r.push({channelId:a,conversationType:n,targetId:i,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",r)}),(function(t){e._logger.info("会话标签状态变更",t),e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._logger.info("标签变更",t),e._send2AllRenderer("tag",t)}))},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){h.info("RTC Room Data Change:",t);var o=JSON.parse(t).list.map((function(e){var t=JSON.parse(e.obj);return{key:t.key,value:t.value,uid:t.operator,timestamp:t.version,status:t.isDeleted?1:0,roomId:t.roomId||""}}));e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,o,n){var r=0;t&&(r|=1),o&&(r|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this._callCppProxy("registerMessageType",e,r,n)},e.prototype.connect=function(e,t,n){var r=this;return this._logger.info("connect ->",e,t,n),this._currentToken===e&&this._connectionStatus===o.ConnectionStatus.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(o.ErrorCode.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,!this._promiseHandler.connect&&this._doConnect(n),new Promise((function(e,t){r._promiseHandler.connect?r._promiseHandler.connect.push({resolve:e,reject:t}):r._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=o.isUndefined(e)?this._reconnectKickEnable:e;this._callCppProxy("connectWithToken",this._currentToken,this._initOptions.apiVersion,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){this._cppProtocol.uploadSDKVersion&&this._cppProtocol.uploadSDKVersion(JSON.stringify(e)),this._logger.info(e)},e.prototype.disconnect=function(){this._cppProtocol.disconnect(!0),this._heartbeat.stop()},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("subscribeUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("setUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getUserStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,r){var i=this,s=n.messageType,a=n.content,c=n.pushContent,u=n.pushData,p=n.directionalUserIdList,l=n.disableNotification,d=n.canIncludeExpansion,C=n.expansion,f=n.isVoipPush,v=n.pushConfig,g=n.channelId,h=n.isMentioned,S=n.mentionedType,_=n.mentionedUserIdList,y=v||{},E=y.iOSConfig,m=y.androidConfig,P=y.pushTitle,T=y.pushContent,R=y.pushData,I=y.disablePushTitle,N=y.forceShowDetailContent,O=y.templateId,M=o.pushConfigsToJSON(E,m);return new Promise((function(n){c=T||c||"",u=R||u||"",l=l||!1,f=f||!1,P=P||"",T=T||"",R=R||"",I=I||!1,N=N||!1,d=d||!1;var v=(null==m?void 0:m.notificationId)||"";if(p=p||[],g=g||"",e===o.ConversationType.GROUP&&h&&a&&(a.mentionedInfo={userIdList:_,type:S||o.MentionedType.ALL}),e===o.ConversationType.GROUP&&s===o.MessageType.READ_RECEIPT_RESPONSE&&a.receiptMessageDic)for(var y in a.receiptMessageDic)p.push(y);var E={};for(var y in C)E[y]={v:""},E[y].v=C[y];var U=O||"",x=i._callCppProxy("sendMessage",(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return t===o.ErrorCode.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===r.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(r),r.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(r),n({code:o.ErrorCode.SUCCESS,data:r}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,s,JSON.stringify(a),p,l,I,N,c,u,v,P,M,U,d,JSON.stringify(E),f,g),b=JSON.parse(x);r&&r(b.messageId)}))},e.prototype.recallMsg=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){var u,p=i.user,l=i.pushContent,d=i.channelId,C=i.extra,f=i.pushConfig,v=i.disableNotification,g=i.isDelete,h={conversationType:e,targetId:t,messageUId:n,sentTime:r,user:p,extra:C,channelId:d,isDelete:g||!1};p&&(h.user=p),C&&(h.extra=C);var S={conversationType:e,targetId:t,senderUserId:s._currentUserId,content:h,objectName:o.MessageType.RECALL,messageUid:n,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:r,channelId:d},_=s._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){a({code:o.ErrorCode.SUCCESS,data:_})}),(function(e){a({code:e})}),o.MessageType.RECALL,JSON.stringify(h),v||!1,(null==f?void 0:f.disablePushTitle)||!1,(null==f?void 0:f.forceShowDetailContent)||!1,l||"",(null==f?void 0:f.pushData)||"",(null===(u=null==f?void 0:f.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==f?void 0:f.pushTitle)||"",o.pushConfigsToJSON(null==f?void 0:f.iOSConfig,null==f?void 0:f.androidConfig),(null==f?void 0:f.templateId)||"",d)}))},e.prototype.getHistoryMessage=function(e,t,n,r,i,s,a){var c=this;return new Promise((function(u,p){n=n||0;var l=0===i,d=r+1,C=c._callCppProxy("getHistoryMessages",e,t,n,d,a,l,s),f=JSON.parse(C).list,v=[];f.reverse();for(var g=0;g<f.length;g++){var h=c._buildMessage(f[g].obj);v[g]=h}u({code:o.ErrorCode.SUCCESS,data:{list:d===v.length?v.slice(1,d):v,hasMore:r<v.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,r,i,s){var a=this;return new Promise((function(c,u){n=n||0;a._callCppProxy("getRemoteHistoryMessages",e,t,n,r,(function(e,t){var n=JSON.parse(e).list,r=[];n.reverse();for(var i=0;i<n.length;i++){var s=a._buildMessage(n[i].obj);r[i]=s}c({code:o.ErrorCode.SUCCESS,data:{list:r,hasMore:!!t}})}),(function(e){c({code:e})}),i,!0,s)}))},e.prototype.deleteRemoteMessage=function(e,t,n,r){var i=this;return new Promise((function(s,a){var c=JSON.stringify(n);i._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,r,(function(){s(o.ErrorCode.SUCCESS)}),s)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(o.ErrorCode.SUCCESS)}),(function(e){s(e)}),r)}))},e.prototype.clearMessages=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("clearMessages",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,r,i){var s=this;return void 0===i&&(i=""),new Promise((function(e,t){for(var n=s._callCppProxy("getConversationList",[1,3,6,7],i),r=JSON.parse(n).list,a=[],c=0;c<r.length;c++)a.push(s._buildConversation(r[c].obj));e({code:o.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getConversation",e,t,n);if(a)i({code:o.ErrorCode.SUCCESS,data:r._buildConversation(a)});else{var c=r._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){r._logger.warn("json parse cppMessagaes error",e),u=[]}var p=null;u.length>0&&(p=r._buildMessage(u[0].obj));var l=r._callCppProxy("getConversationNotificationStatus",e,t,n),d=r._callCppProxy("getConversationTopStatus",e,t,n);i({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var r=this._callCppProxy("removeConversation",e,t,n);return this._logger.info("removeConversation result -> ".concat(r)),Promise.resolve(r?o.ErrorCode.SUCCESS:o.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(r,i){var s=[];s=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],n._callCppProxy("clearConversations",s,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var r=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(i){var s=r._callCppProxy("getUnreadCount",e,t,n);i({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(i,s){r._callCppProxy("clearUnreadCount",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("clearUnreadCountByTimestamp",e,t,n,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=r._buildMessage(a);i({code:o.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,r){var i=this;return void 0===r&&(r=""),new Promise((function(s,a){i._logger.info("setConversationToTop",e,t,n,r,true),i._callCppProxy("setConversationToTop",e,t,n,r,true),s(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("setConversationHidden",e,t,n,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._logger.info("setConversationNotificationStatus",e,t,n,r),i._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(o.ErrorCode.SUCCESS)}),s,r)}))},e.prototype.setConversationStatus=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){s._logger.info("setConversationStatus",e,t,n,r,i,true),s._callCppProxy("setConversationStatus",e,t,n,r,(function(){a(o.ErrorCode.SUCCESS)}),a,i,true)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var r=this;return new Promise((function(i,s){var a=r._callCppProxy("getConversationNotificationStatus",e,t,n);i({code:o.ErrorCode.SUCCESS,data:a?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,r){var i=this;return new Promise((function(s,a){r=r||[1,3,6,7];for(var c=i._callCppProxy("searchConversationByContent",r,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=i._buildConversation(u[l].obj);s({code:o.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchMessageByContent=function(e,t,n,r,i,s,a){var c=this;return new Promise((function(s,u){c._callCppProxy("searchMessageByContent",e,t,n,r,i,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],i=0;i<n.length;i++)r[i]=c._buildMessage(n[i].obj);s({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}),a)}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addToBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("removeFromBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var r=this,i=n.content,s=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,C=n.isUnread,f=n.messageUId,v=n.disableNotification,g=n.canIncludeExpansion,h=n.expansionMsg,S=n.channelId;return i=JSON.stringify(i),new Promise((function(n,_){var y=C?0:1,E=r._callCppProxy("insertMessage",e,t,s,a,i,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,f,v,g,h,S);r._logger.info("after insert msg",E);var m=r._buildMessage(E,{isOffLineMessage:!1});m.messageUId=f,m.sentTime=l,n({code:-1===m.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:m})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteMessages",e),n(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,r,i){var s=this;return new Promise((function(a,c){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,r,i),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,r){var i=t._callCppProxy("getMessage",e);t._logger.info("getMessage ===>",i);var s=t._buildMessage(i,{isOffLineMessage:!1});n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setMessageContent=function(e,t,n){var r=this;return new Promise((function(i,s){t=JSON.stringify(t),r._callCppProxy("setMessageContent",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setMessageSearchField",e,t,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("setMessageSentStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("setMessageReceivedStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,r=t.targetId,i=t.isTop,s=t.notificationStatus,a=t.channelId;if(void 0!==i&&void 0===s)return this.setConversationToTop(n,r,i,a);if(void 0!==s&&void 0===i){var c=s===o.NotificationStatus.OPEN;return this.setConversationNotificationStatus(n,r,c,a)}c=s===o.NotificationStatus.OPEN;return this.setConversationStatus(n,r,c,i,a)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){r._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(r._callCppProxy("getMessage",e)).messageId;r.setMessageReceivedStatus(t,1)}catch(t){r._logger.warn("format message error, messageUId: "+e)}})),i({code:o.ErrorCode.SUCCESS})}),(function(e){i({code:e})}))}))},e.prototype.getMessageReader=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("getMessageReader",e,n,t,(function(e,n){r._logger.info("getMessageReader -> ",e,n);var s=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;s.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:s.length,totalCount:n};r._updateReadReceiptInfo(t,c),i({code:o.ErrorCode.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){i({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("quitChatRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],r=[];if(n.length>0)for(var s=0;s<n.length;s++)r.push(JSON.parse(n[s].obj));i({code:o.ErrorCode.SUCCESS,data:{userInfos:r,userCount:t}})}),(function(e){i({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,r){var i=this;return new Promise((function(s,a){i._callCppProxy("getChatroomHistoryMessage",e,t,n,r,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return i._buildMessage(e.obj)}))}catch(e){t.list=[]}s({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(r,i){var s='[{"key":"'+t.key+'", "value":"'+t.value+'"}]';n._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,r=[t.key];return new Promise((function(i,s){n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(r){var i=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,i,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return C(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=r.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,r){var i=this;return n=n||"",r=r||"",new Promise((function(s){var a;a=r&&"uploads"!==r?t||"":o.getUploadFileName(e,t),i._callCppProxy("getUploadToken",e,a,n,r,(function(e,t,n,r,i,c,u,p,l,d,C,f,v,g,h,S,_,y){s({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:r,osskeyId:i,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:C,s3Policy:f,s3Signature:v,s3BucketName:g,stcAuthorization:h,stcContentSha256:S,stcDate:_,stcBucketName:y}})}),(function(e){s({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,r){var i=this;return new Promise((function(s){i._callCppProxy("getDownloadUrl",e,n,r,t-1,(function(e){s({code:o.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return y(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("getVoIPKey",e,t,"",(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.joinRTCRoom=function(e,t,n,r,i,s){var a=this;return new Promise((function(c){var u=i?JSON.stringify(i):"",p=s?JSON.stringify(s):"";a._callCppProxy("joinRTCRoom",e,t,n||0,r||o.RTCJoinType.KICK,(function(e,t,n,r,i,s){var a=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:T(r),kvEntries:[],offlineKickTime:s};a.forEach((function(e){var t=e.id,o=e.data;u.users[t]=o[0]||{}})),c({code:o.ErrorCode.SUCCESS,data:u})}),(function(e){a._logger.error("joinRTCRoom error -> ".concat(e)),c({code:e})}),"","",u,p)}))},e.prototype.quitRTCRoom=function(e){var t=this;return new Promise((function(n){t._callCppProxy("exitRTCRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.rtcPing=function(e,t,n){var r=this;return new Promise((function(t){r._callCppProxy("sendRTCPing",e,(function(){t(o.ErrorCode.SUCCESS)}),t)}))},e.prototype.getRTCRoomInfo=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCResouce",e,2,(function(e){n({code:o.ErrorCode.SUCCESS,data:JSON.parse(e)})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfoList=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getRTCResouce",e,1,(function(e){var t=JSON.parse(e).list,r={users:{}};t.forEach((function(e){var t=e.id,o=e.data;r.users[t]=o[0]||{}})),n({code:o.ErrorCode.SUCCESS,data:r})}),(function(e){n({code:e})}))}))},e.prototype.getRTCUserInfo=function(e){throw new Error("Method not implemented.")},e.prototype.setRTCUserInfo=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setRTCInnerData",e,o.RTCApiType.PERSON,t,n,"","",(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.removeRTCUserInfo=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.PERSON,t,"","",(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.setRTCData=function(e,t,n,r,i,s){var a=this;return new Promise((function(c){var u={room_innder:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCInnerData",e,o.RTCApiType.ROOM,t,n,r,i,s,c)},room_outer:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCOuterData",e,o.RTCApiType.ROOM,t,n,r,i,s,c)},user_innder:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCInnerData",e,o.RTCApiType.PERSON,t,n,r,i,s,c)},user_outer:function(e,t,n,r,i,s,c){a._callCppProxy("setRTCOuterData",e,o.RTCApiType.PERSON,t,n,r,i,s,c)}},p=o.RTCApiType.PERSON===i?"user":"room",l=r?"inner":"outer",d=u["".concat(p,"_").concat(l)];if(d){var C=(null==s?void 0:s.content)?JSON.stringify(s.content):"",f=(null==s?void 0:s.name)||"";d(e,t,n,f,C,(function(){c(o.ErrorCode.SUCCESS)}),(function(e){c(e)}))}}))},e.prototype.setRTCTotalRes=function(e,t,n,r,i){var s=this;return new Promise((function(a){var c=t.name,u=t.content;s._callCppProxy("setUserResource",e,c,u,r,n,i,(function(){return a(o.ErrorCode.SUCCESS)}),a)}))},e.prototype.setRTCCDNUris=function(e,t,n){var r=this;return new Promise((function(i){r._callCppProxy("setRTCCDNUris",e,t,n,(function(){return i(o.ErrorCode.SUCCESS)}))}))},e.prototype.getRTCData=function(e,t,n,r){var i=this;return new Promise((function(s){var a={room_inner:function(e,t,n,r){i._callCppProxy("getRTCInnerData",e,o.RTCApiType.ROOM,t,n,r).getRTCInnerData()},room_outer:function(e,t,n,r){i._callCppProxy("getRTCOuterData",e,o.RTCApiType.ROOM,t,n,r)}},c=o.RTCApiType.PERSON===r?"user":"room",u=n?"inner":"outer",p=a["".concat(c,"_").concat(u)];p&&p(e,t,(function(e){var t=JSON.parse(e),n={};t.list.forEach((function(e){var t=Object.keys(e)[0],o=Object.values(e)[0];n[t]=o})),s({code:o.ErrorCode.SUCCESS,data:n})}),(function(e){s({code:e})}))}))},e.prototype.removeRTCData=function(e,t,n,r,i){var s=this;return new Promise((function(a){s._callCppProxy;var c={room_inner:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.ROOM,t,n,r,i,a)},room_outer:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCOuterData",e,o.RTCApiType.ROOM,t,n,r,i,a)},user_inner:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCInnerData",e,o.RTCApiType.PERSON,t,n,r,i,a)},user_outer:function(e,t,n,r,i,a){s._callCppProxy("deleteRTCOuterData",e,o.RTCApiType.PERSON,t,n,r,i,a)}},u=o.RTCApiType.PERSON===r?"user":"room",p=n?"inner":"outer",l=c["".concat(u,"_").concat(p)];if(l){var d=(null==i?void 0:i.content)?JSON.stringify(i.content):"",C=(null==i?void 0:i.name)||"";l(e,t,C,d,(function(){a(o.ErrorCode.SUCCESS)}),(function(e){a(e)}))}}))},e.prototype.setRTCOutData=function(e,t,o,n){throw new Error("Method not implemented.")},e.prototype.getRTCOutData=function(e,t){throw new Error("Method not implemented.")},e.prototype.getRTCToken=function(e,t,n){var r=this;return new Promise((function(t){r._callCppProxy("getRTCToken",e,(function(e){t({code:o.ErrorCode.SUCCESS,data:{rtcToken:e}})}),(function(e){t({code:e})}))}))},e.prototype.setRTCState=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setRTCUserState",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getRTCUserList=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getRTCUsers",e,1,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteTag",e,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("getTags");e._logger.info("getTagList -> ",r);var i=e._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(r,i){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(r,i){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(r,i){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,r){var i=this;return new Promise((function(s,a){var c=i._callCppProxy("getConversationsForTagByPage",e,t,n||20,r||"");i._logger.info("getConversationListByTag -> ",c);var u=i._convertResultList(c,(function(e){return d(d({},i._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(r,i){var s=n._callCppProxy("getConversationUnreadCountForTag",e,t);n._logger.info("getUnreadCountByTag -> ",s),r({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var r=this;return new Promise((function(i,s){r._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){i({code:o.ErrorCode.SUCCESS})}),(function(e){i({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,r){var i=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||"");t._logger.info("getTagsForConversation -> ",i);var s=t._convertResultList(i,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.joinLivingRoomAsAudience=function(e,t,n){return C(this,void 0,void 0,(function(){var n=this;return f(this,(function(r){return[2,new Promise((function(r,i){n._cppProtocol.audienceJoinRoom(e,t,(function(e,t){h.info("joinLivingRoomAsAudience data:",e,t),r({data:{token:e,kvEntries:P(t)},code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))]}))}))},e.prototype.quitLivingRoomAsAudience=function(e){var t=this;return new Promise((function(n,r){t._cppProtocol.audienceLeaveRoom(e,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.switchLivingRoomRole=function(e,t,n){var r=this;return void 0===n&&(n=o.LiveType.AUDIO_AND_VIDEO),new Promise((function(i,s){r._cppProtocol.switchRole(e,n,t,"","",(function(e,t,n,r,s,a){h.info("switchLivingRoomRole data:",e,t,n,r,s);var c=JSON.parse(e).list,u={token:t,sessionId:n,users:{},roomInfo:T(r),kvEntries:P(s),offlineKickTime:a};c.forEach((function(e){var t=e.id,o=e.data;u.users[t]=o[0]||{}})),i({code:o.ErrorCode.SUCCESS,data:u})}),(function(e){i({code:e})}))}))},e.prototype.getRTCJoinedUserInfo=function(e){var t=this;return new Promise((function(e){t._callCppProxy("queryJoinedRoom",(function(n){t._logger.info("getRTCJoinedUserInfo -> ",n);var r=JSON.parse(n).list[0];e(r?{code:o.ErrorCode.SUCCESS,data:[JSON.parse(r.obj)]}:{code:o.ErrorCode.SUCCESS})}),(function(t){e({code:t})}))}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.requestRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteTimeout,p=e.inviteInfo;t._callCppProxy("livePKInvitation",i,a,s,p,c,u,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.cancelRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.invitedRoomId,a=e.invitedUserId,c=e.inviteSessionId,u=e.inviteInfo;t._callCppProxy("livePKCancel",i,a,s,u,c,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.responseRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.inviteUserId,a=e.inviteRoomId,c=e.inviteSessionId,u=e.content,p=e.key,l=e.value,d=e.agree?1:0;t._callCppProxy("livePKAnswer",i,d,s,a,c,u,p,l,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.endRoomPK=function(e){var t=this;return new Promise((function(n,r){var i=e.roomId,s=e.endRoomId,a=e.sessionId,c=e.content,u=e.keys;t._callCppProxy("livePKHangup",i,s,a,c,u,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,r){var i=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",i,s,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e}();module.exports=function(e){return function(e,t){return h.setLogLevel(null==t?void 0:t.logLevel),h.setLogStdout(null==t?void 0:t.logStdout),new N(e,null==t?void 0:t.dbpath,null==t?void 0:t.reconnectKickEnable)}(l,e)};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"types": "index.d.ts",
|
|
13
13
|
"module": "index.esm.js",
|
|
14
|
-
"version": "5.3.
|
|
14
|
+
"version": "5.3.3",
|
|
15
15
|
"author": "pass-web@rongcloud.cn",
|
|
16
16
|
"license": "LGPL 2.1",
|
|
17
17
|
"homepage": "https://www.rongcloud.cn",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"globals": "RCMain"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@rongcloud/engine": "=5.3.
|
|
25
|
+
"@rongcloud/engine": "=5.3.3"
|
|
26
26
|
}
|
|
27
27
|
}
|