此页面为接收端es.js,部分js代码没粘出来。但是好好捋流程应该够了
如果您这边分开调用理解的不是太好可以借鉴我之前发布的websocket专题1~5参考查阅(忘记了是否都被发布)
connWSController(esClientId); /** * 青红标识:青 */var BLUE_OR_RED_BLUE = "BLUE";/** * 青红标识:红 */var BLUE_OR_RED_RED = "RED";/** * 下一局或加时赛标识:下一局 */var ROUND_GLOD_ROUND = "ROUND_GLOD_ROUND";/** * 下一局或加时赛标识:加时赛 */var ROUND_GLOD_GLOD = "ROUND_GLOD_GLOD";/** * ControllerWebSocket回调方法 */function controllerHandle(wsmessage){ console.log("" + wsmessage);var wsmessageJson = JSON.parse(wsmessage);if(wsmessageJson.CMD == CMD_CLOSE_ES){ window.location.href = serviceUrl + "/tkdtas/tasController/screensaver"; }else if(wsmessageJson.CMD == CMD_PAUSE_TIME){$("#pauseTimeContainer").show();}else if(wsmessageJson.CMD == CMD_START_TIME){$("#pauseTimeContainer").hide();}else if(wsmessageJson.CMD == CMD_MANUALS_CORING){var blueOrRed = wsmessageJson.blueOrRed;var score = wsmessageJson.score;if(blueOrRed == BLUE_OR_RED_BLUE){$("#blueScoreContainer").html(score);}else if(blueOrRed == BLUE_OR_RED_RED){$("#redScoreContainer").html(score);}}else if(wsmessageJson.CMD == CMD_MANUALS_WARNING){var blueOrRed = wsmessageJson.blueOrRed;var warning = wsmessageJson.warning;var warningCount = Number(warning);if(blueOrRed == BLUE_OR_RED_BLUE){$(".bWarningContainer").hide();$("#blueWarningCountContainer").html(warningCount < 10 ? "0"+warningCount : warningCount);console.log("warningCount:"+warningCount);if(warningCount>0){$("#blueWarningCountContainer").css("display","");}if(warningCount<1){$("#blueWarningCountContainer").css("display","none");}for(var i=0; i0){$("#redWarningCountContainer").css("display","");}if(warningCount<1){$("#redWarningCountContainer").css("display","none");}for(var i=0; i 级别名称:" + levelName);
return levelName;
}
/**
* 获取性别
* @param data
* @returns
*/
function getLevelSex(data){
if(data.levelSex == "M"){
levelSex ="男子";
}else if(data.levelSex == "W"){
levelSex ="女子";
}else if(data.levelSex == "B"){
levelSex ="混合";
}
return levelSex;
}
/**
* 获取级别类别;个人/团体
* @param data
* @returns
*/
function getMatchType(data){
if(data.matchType == "T_PC"){
return "个人竞技";
}else if(data.matchType == "T_TC"){
return "团体竞技";
}
console.log("未能识别的级别类型:LEVEL_TYPE->"+data.levelType);
return "";
}
//{"arenaFlag":"A","blueAthleteId":"blue1","blueAthleteName":"古力娜扎","blueTeamName":"北京队",
//"eventId":"bisaidandubianhao","levelGroup":"成年组","levelKg":55,"levelSex":"M","matchDay":1,
//"matchId":"bisaiweiyibiaoshi","matchNo":"001","matchType":"T_PC","redAthleteId":"red1",
//"redAthleteName":"迪丽热巴","redTeamName":"上海队","stage":"1/8"}
网友评论