@xuda.io/runtime-bundle
Version:
The Xuda Runtime Bundle refers to a collection of scripts and libraries packaged together to provide the necessary runtime environment for executing plugins or components in the Xuda platform.
1 lines • 2.5 kB
JavaScript
const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const init_peer=async function(SESSION_ID,peer_regional_server){var _session=_this.SESSION_OBJ[SESSION_ID];const peer=new Peer(_session.SYS_GLOBAL_OBJ_CLIENT_INFO.fingerprint,{host:`https://${peer_regional_server}`,path:"/peer",secure:true,config:{iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.l.google.com:5349"},{urls:"stun:stun1.l.google.com:3478"},{urls:"stun:stun1.l.google.com:5349"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun2.l.google.com:5349"},{urls:"stun:stun3.l.google.com:3478"},{urls:"stun:stun3.l.google.com:5349"},{urls:"stun:stun4.l.google.com:19302"},{urls:"stun:stun4.l.google.com:5349"}]}});SUPPORT_PEER=peer;peer.on("open",function(peer_id){func.common.db(SESSION_ID,"get_support",{peer_id:peer_id});setTimeout(()=>{$("body").addClass("get_support_request");$("body").remove(".get_support_request_title").append("<div class='get_support_request_title'>Support processing</div>")},2e3)});peer.on("connection",async function(conn){conn.on("open",()=>{SUPPORT_PEER_CONN=conn.send.bind(conn);$("body").addClass("get_support_online")});const peer_actions_module=await func.common.get_module(SESSION_ID,"xuda-peer-actions-module.esm.js");conn.on("data",data=>{console.log(data);peer_actions_module.peer_actions(SESSION_ID,SUPPORT_PEER_CONN,data)});conn.on("close",function(conn){$("body").removeClass("get_support_online")})});peer.on("call",function(call){const displayMediaStreamConstraints={video:{cursor:"always"},audio:true,preferCurrentTab:true};const success=function(stream){call.answer(stream)};const error=function(error){call.answer(error)};if(navigator.mediaDevices.getDisplayMedia){navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}else{navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}});peer.on("error",function(err){console.error(err)})};export const terminate_peer=async function(SESSION_ID){SUPPORT_PEER.disconnect();$("body").removeClass("get_support_request");$("body").find(".get_support_request_title").remove();$("body").removeClass("get_support_online");$("body").find(".get_support_online_title").remove();func.common.db(SESSION_ID,"cancel_support",{});SUPPORT_PEER=null;SUPPORT_PEER_CONN=null};