|
|
@@ -5,19 +5,25 @@ export class LiveWS {
|
|
|
* @param {string} url - WebSocket 服务器地址
|
|
|
* @param {number} liveId - 直播间ID
|
|
|
* @param {number} userId - 用户ID
|
|
|
+ * @param {string} tenantCode - 租户编码(多租户隔离)
|
|
|
* @param {number} checkInterval - 检查连接状态的时间间隔,单位毫秒
|
|
|
* @param {number} reconnectDelay - 连接断开后重连的延迟,单位毫秒
|
|
|
*/
|
|
|
- constructor(url, liveId, userId, checkInterval = 5000, reconnectDelay = 3000) {
|
|
|
+ constructor(url, liveId, userId, tenantCode, checkInterval = 5000, reconnectDelay = 3000) {
|
|
|
let timestamp = new Date().getTime()
|
|
|
let userType = 1
|
|
|
let signature = CryptoJS.HmacSHA256(
|
|
|
CryptoJS.enc.Utf8.parse('' + liveId + userId + userType + timestamp),
|
|
|
CryptoJS.enc.Utf8.parse(timestamp)).toString(CryptoJS.enc.Hex)
|
|
|
- this.url = url + `?liveId=${liveId}&userId=${userId}&userType=${userType}×tamp=${timestamp}&signature=${signature}`;
|
|
|
+ let query = `liveId=${liveId}&userId=${userId}&userType=${userType}×tamp=${timestamp}&signature=${signature}`;
|
|
|
+ if (tenantCode && tenantCode !== 'undefined' && tenantCode !== 'null') {
|
|
|
+ query += `&tenantCode=${tenantCode}`;
|
|
|
+ }
|
|
|
+ this.url = url + '?' + query;
|
|
|
console.log(this.url)
|
|
|
this.liveId = liveId;
|
|
|
this.userId = userId;
|
|
|
+ this.tenantCode = tenantCode;
|
|
|
this.checkInterval = checkInterval;
|
|
|
this.reconnectDelay = reconnectDelay;
|
|
|
this.ws = null;
|