替换wss

This commit is contained in:
guoshengxiong 2025-10-17 18:47:14 +08:00
parent 32913ad718
commit 8c228f1495

View File

@ -14,6 +14,7 @@ import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.jeecg.common.util.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import java.util.*;
@ -25,6 +26,18 @@ import java.util.*;
**/
@Slf4j
public class HikVideoUtil {
private static String replaceWssFrom;
private static String replaceWssTo;
@Value("${replaceWssFrom:wss://hrdl.zhgdyun.com}")
public void setReplaceWssFrom(String replaceWssFrom) {
HikVideoUtil.replaceWssFrom = replaceWssFrom;
}
@Value("${replaceWssTo:wss://sp.szjxj.com}")
public void setReplaceWssTo(String replaceWssTo) {
HikVideoUtil.replaceWssTo = replaceWssTo;
}
private static final String ARTEMIS_PATH = "/artemis";
@ -81,6 +94,10 @@ public class HikVideoUtil {
if ("0".equals((String) json.get("code"))) {
JSONObject object2 = (JSONObject) json.get("data");
url = (String) object2.get("url");
//替换wss域名
if (url.startsWith(HikVideoUtil.replaceWssFrom)) {
url = StrUtil.replace(url, HikVideoUtil.replaceWssFrom, HikVideoUtil.replaceWssTo);
}
}
} else {
throw new OpenAlertException(MessageUtil.get("failErr"));