public void updateLikesActionString moveIdStr FlowContext flowContext try long userId = flowContextgetUserId; LogDebuglogupdateLikesAction moveId + moveIdStr;
public void updateLikesAction(String moveIdStr, FlowContext flowContext) { try { long userId = flowContext.getUserId(); LogDebug.log("updateLikesAction moveId:" + moveIdStr); UserIdType userIdType = GM.me.checkUserId(userId); if (userIdType == UserIdType.DEVICE || userIdType == UserIdType.ERROR_USERID) { return; } long moveId = Long.parseLong(moveIdStr); if (!GM.me.getAllOnlineCarsRealRecordsMap().containsKey(moveId)) { return; }
//车辆在线
CarRealRecord carRealRecord = GM.me.getAllOnlineCarsRealRecordsMap().get(moveId);
//1.更新车辆实训记录总点赞数
carRealRecord.setLikes(carRealRecord.getLikes() + 1);
//2.判断当前是否有人在实训,给在实训的用户更新点赞
if (GM.me.getUserRealRecordMapNow().containsKey(moveId)) {
UserRealRecord userRealRecord = GM.me.getUserRealRecordMapNow().get(moveId);
if (userRealRecord.getStartDatetime() != null && userRealRecord.getEndDatetime() == null) {
userRealRecord.setLikes(userRealRecord.getLikes() + 1);
}
}
int isLike = 0;
//当前点赞是否成功 0 -1
BroadcastContext broadcastContext1 = BrokerClientHelper.getBroadcastContext();
CmdInfo cmdInfo1 = CmdInfo.getCmdInfo(ViewersAndLikesCmd.cmd, ViewersAndLikesCmd.updateLikesAction);
StringValue stringValue1 = new StringValue();
stringValue1.value = isLike + "";
broadcastContext1.broadcast(cmdInfo1, stringValue1, userId);
//获取总人数
List<Long> userIds = GM.me.getViewersByMoveIdNow(moveId);
//当前所有人当前总的点赞数
BroadcastContext broadcastContext2 = BrokerClientHelper.getBroadcastContext();
CmdInfo cmdInfo2 = CmdInfo.getCmdInfo(ViewersAndLikesCmd.cmd, ViewersAndLikesCmd.getAllLiveLikesAction);
StringValue stringValue2 = new StringValue();
stringValue2.value = carRealRecord.getLikes() + "";
broadcastContext2.broadcast(cmdInfo2, stringValue2, userIds);
} catch (Exception ignored) {
}
原文地址: http://www.cveoy.top/t/topic/i1yu 著作权归作者所有。请勿转载和采集!