var client = XYClient.DispatcherClient.getInstance(); client.enableLog = true; client.registStateChange.on((para) => { var state = para.state; // if (para.state = XYClient.ConferenceMemberState) { // console.log(1); // }else{ // console.log(2); // } var stateStr; switch (state) { case 1: stateStr = "registed"; break; case 2: stateStr = "unregisted"; break; case 3: stateStr = "connect error"; break; case 4: stateStr = "password error"; break; case 5: stateStr = "user not exist"; break; case 6: stateStr = "server error"; break; case 7: stateStr = "other error"; break; case 8: stateStr = "repeat login"; break; case 9: stateStr = "type error"; break; case 10: stateStr = "被强制下线"; break; default: break; } alert("注册状态:" + stateStr); mylog("onRegitStateChange: " + stateStr); }); client.serverConnectStateChanged.on((state) => { var stateStr; switch (state) { case 1: stateStr = "connected"; break; case 0: stateStr = "disconect"; break; default: break; } mylog("serverConectStateChanged state: " + stateStr); }); function regist() { // var ip = $("txtServerIP").value; // var port = $("txtServerPort").value; // var businesPort = $("txtbusinesPort").value; // var userName = $("txtUsername").value; // var password = $("txtPassword").value; // var userType = $("cmbUserType").value; var ip = "192.168.1.134"; //$("txtServerIP").value; var port = "7443"; ////$("txtServerPort").value; var businesPort = "60002"; //$("txtbusinesPort").value; var userName = "2000"; //$("txtUsername").value; var password = "123456"; //$("txtPassword").value; var userType = "2"; //$("cmbUserType").value; // var options = { ip, port, businesPort, userName, password, userType, null: HTMLVideoElement, videoRemoteElement } var resourceUrl = ""; var businessResourceUrl = ""; // var resourceUrl = "softswitch"; // var businessResourceUrl = "dispatch"; var options = { ip, port, businesPort, userName, password, userType, resourceUrl, businessResourceUrl, }; // var options = { ip, port, businesPort, userName, password, userType } client.regist(options); } function unRegist() { client.unRegist(); } function isRegisted() { alert("已注册: " + client.isRegisted); } // function onForceKickoutClick() { // client.forceKickout().then( (result) => { // mylog("强制其他登录者退出 成功"); // } ).catch( (reason)=>{ // mylog("强制其他登录者退出 失败:" + JSON.stringify(reason)); // } ) // } // function onGetLoginStateClick() { // client.getLoginState().then( (result) => { // mylog("获取登录状态成功: " + JSON.stringify(result)); // } ).catch( (reason)=>{ // mylog("获取登录状态失败:" + JSON.stringify(reason)); // } ) // } function onForceLoginClick() { client .forceLogin() .then((result) => { mylog("强制登录者成功"); }) .catch((reason) => { mylog("强制登录者失败:" + JSON.stringify(reason)); }); } function mylog(msg) { msg = getNowFormatDate() + " : " + msg + "\r\n"; console.log("msg ====>", msg); } function getNowFormatDate() { var date = new Date(); var seperator1 = "/"; //设置成自己想要的日期格式 年/月/日 var seperator2 = ":"; //设置成自己想要的时间格式 时:分:秒 var month = date.getMonth() + 1; //月 var strDate = date.getDate(); //日 if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + date.getMinutes() + seperator2 + date.getSeconds(); return currentdate; } function clearLogClick() { $("output").value = ""; } function $(itemID) { if (document.getElementById) { return document.getElementById(itemID); } else { return document.all(itemID); } } function onbindPhoneHandleClick() { var left = $("txtLeftPhone").value; var right = $("txtRightPhone").value; client .bindPhoneHandle(left, right) .then((result) => { mylog("绑定左右话柄成功"); }) .catch((error) => { mylog("绑定左右话柄失败 :" + JSON.stringify(error)); }); } function handleChange(index) { var handleMode = 0; switch (index) { case 1: handleMode = 1; break; case 2: handleMode = 2; break; default: break; } client.handleMode = handleMode; }