|
@@ -5,16 +5,19 @@ export class LiveWS {
|
|
|
* @param {string} url - WebSocket 服务器地址
|
|
* @param {string} url - WebSocket 服务器地址
|
|
|
* @param {number} liveId - 直播间ID
|
|
* @param {number} liveId - 直播间ID
|
|
|
* @param {number} userId - 用户ID
|
|
* @param {number} userId - 用户ID
|
|
|
|
|
+ * @param {string} tenantCode - 租户编码(多租户SaaS)
|
|
|
* @param {number} checkInterval - 检查连接状态的时间间隔,单位毫秒
|
|
* @param {number} checkInterval - 检查连接状态的时间间隔,单位毫秒
|
|
|
* @param {number} reconnectDelay - 连接断开后重连的延迟,单位毫秒
|
|
* @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 timestamp = new Date().getTime()
|
|
|
let userType = 1
|
|
let userType = 1
|
|
|
let signature = CryptoJS.HmacSHA256(
|
|
let signature = CryptoJS.HmacSHA256(
|
|
|
CryptoJS.enc.Utf8.parse('' + liveId + userId + userType + timestamp),
|
|
CryptoJS.enc.Utf8.parse('' + liveId + userId + userType + timestamp),
|
|
|
CryptoJS.enc.Utf8.parse(timestamp)).toString(CryptoJS.enc.Hex)
|
|
CryptoJS.enc.Utf8.parse(timestamp)).toString(CryptoJS.enc.Hex)
|
|
|
- this.url = url + `?liveId=${liveId}&userId=${userId}&userType=${userType}×tamp=${timestamp}&signature=${signature}`;
|
|
|
|
|
|
|
+ // 多租户SaaS:tenantCode 作为查询参数传递
|
|
|
|
|
+ const tenantParam = tenantCode ? `&tenantCode=${tenantCode}` : '';
|
|
|
|
|
+ this.url = url + `?liveId=${liveId}&userId=${userId}&userType=${userType}×tamp=${timestamp}&signature=${signature}${tenantParam}`;
|
|
|
this.liveId = liveId;
|
|
this.liveId = liveId;
|
|
|
this.userId = userId;
|
|
this.userId = userId;
|
|
|
this.checkInterval = checkInterval;
|
|
this.checkInterval = checkInterval;
|