Merge pull request #84 from kasmtech/bugfix/KASM-5409_seperate_display_traffic_by_session

Bugfix/kasm 5409 seperate display traffic by session
This commit is contained in:
j-travis 2024-01-05 13:57:25 -05:00 committed by GitHub
commit 246dbd4999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -104,7 +104,7 @@ const UI = {
if (UI.supportsBroadcastChannel) { if (UI.supportsBroadcastChannel) {
console.log('add event listener') console.log('add event listener')
UI.controlChannel = new BroadcastChannel("registrationChannel"); UI.controlChannel = new BroadcastChannel(UI.rfb.connectionID);
UI.controlChannel.addEventListener('message', UI.handleControlMessage) UI.controlChannel.addEventListener('message', UI.handleControlMessage)
} }

View File

@ -124,7 +124,7 @@ export default class Display {
// ===== PROPERTIES ===== // ===== PROPERTIES =====
get screens() { return this._screens; } get screens() { return this._screens; }
get screenId() { return this._screenID; } get screenID() { return this._screenID; }
get screenIndex() { get screenIndex() {
// A secondary screen should not have a screen index of 0, but it will be 0 until registration is complete // A secondary screen should not have a screen index of 0, but it will be 0 until registration is complete
// returning a -1 lets the caller know the screen has not been registered yet // returning a -1 lets the caller know the screen has not been registered yet

View File

@ -123,7 +123,7 @@ export default class RFB extends EventTargetMixin {
this._supportsContinuousUpdates = false; this._supportsContinuousUpdates = false;
this._enabledContinuousUpdates = false; this._enabledContinuousUpdates = false;
this._supportsSetDesktopSize = false; this._supportsSetDesktopSize = false;
this._screenID = uuidv4(); this._connectionID = window.location.href.split('?')[0].match(/^(.+)(\/)/)[0];
this._screenIndex = 0; this._screenIndex = 0;
this._screenFlags = 0; this._screenFlags = 0;
this._qemuExtKeyEventSupported = false; this._qemuExtKeyEventSupported = false;
@ -220,7 +220,7 @@ export default class RFB extends EventTargetMixin {
this._secondaryDisplays = {}; this._secondaryDisplays = {};
this._supportsBroadcastChannel = (typeof BroadcastChannel !== "undefined"); this._supportsBroadcastChannel = (typeof BroadcastChannel !== "undefined");
if (this._supportsBroadcastChannel) { if (this._supportsBroadcastChannel) {
this._controlChannel = new BroadcastChannel("registrationChannel"); this._controlChannel = new BroadcastChannel(this._connectionID);
this._controlChannel.addEventListener('message', this._handleControlMessage.bind(this)); this._controlChannel.addEventListener('message', this._handleControlMessage.bind(this));
Log.Debug("Attached to registrationChannel for secondary displays.") Log.Debug("Attached to registrationChannel for secondary displays.")
@ -332,6 +332,8 @@ export default class RFB extends EventTargetMixin {
// ===== PROPERTIES ===== // ===== PROPERTIES =====
get connectionID() { return this._connectionID; }
get translateShortcuts() { return this._keyboard.translateShortcuts; } get translateShortcuts() { return this._keyboard.translateShortcuts; }
set translateShortcuts(value) { set translateShortcuts(value) {
this._keyboard.translateShortcuts = value; this._keyboard.translateShortcuts = value;
@ -1375,7 +1377,7 @@ export default class RFB extends EventTargetMixin {
this._sock.close(); this._sock.close();
} else { } else {
if (this._primaryDisplayChannel) { if (this._primaryDisplayChannel) {
this._primaryDisplayChannel.postMessage({eventType: 'unregister', screenID: this._screenID}) this._primaryDisplayChannel.postMessage({eventType: 'unregister', screenID: this._display.screenID})
this._primaryDisplayChannel.removeEventListener('message', this._handleSecondaryDisplayMessage); this._primaryDisplayChannel.removeEventListener('message', this._handleSecondaryDisplayMessage);
this._primaryDisplayChannel.close(); this._primaryDisplayChannel.close();
this._primaryDisplayChannel = null; this._primaryDisplayChannel = null;
@ -1713,7 +1715,7 @@ export default class RFB extends EventTargetMixin {
let message = { let message = {
eventType: messageType, eventType: messageType,
args: data, args: data,
screenId: this._display.screenId, screenID: this._display.screenID,
screenIndex: this._display.screenIndex, screenIndex: this._display.screenIndex,
mouseLastScreenIndex: this._mouseLastScreenIndex, mouseLastScreenIndex: this._mouseLastScreenIndex,
} }
@ -1834,7 +1836,7 @@ export default class RFB extends EventTargetMixin {
if (!this._isPrimaryDisplay){ if (!this._isPrimaryDisplay){
let message = { let message = {
eventType: 'unregister', eventType: 'unregister',
screenID: this._display.screenId screenID: this._display.screenID
} }
this._controlChannel.postMessage(message); this._controlChannel.postMessage(message);
} }