mirror of
https://github.com/novnc/noVNC.git
synced 2026-06-06 20:39:39 +00:00
Don't abuse state change function for messages
This doesn't even work anymore since we fixed it to ignore changes to the current state. Add a separate callback for notifications instead.
This commit is contained in:
35
core/rfb.js
35
core/rfb.js
@@ -158,6 +158,7 @@
|
||||
|
||||
// Callback functions
|
||||
'onUpdateState': function () { }, // onUpdateState(rfb, state, oldstate, statusMsg): state update/change
|
||||
'onNotification': function () { }, // onNotification(rfb, msg, level, options): notification for UI
|
||||
'onPasswordRequired': function () { }, // onPasswordRequired(rfb, msg): VNC password is required
|
||||
'onClipboard': function () { }, // onClipboard(rfb, text): RFB clipboard contents received
|
||||
'onBell': function () { }, // onBell(rfb): RFB Bell message received
|
||||
@@ -535,6 +536,33 @@
|
||||
return false;
|
||||
},
|
||||
|
||||
/*
|
||||
* Send a notification to the UI. Valid levels are:
|
||||
* 'normal'|'warn'|'error'
|
||||
*
|
||||
* NOTE: Options could be added in the future.
|
||||
* NOTE: If this function is called multiple times, remember that the
|
||||
* interface could be only showing the latest notification.
|
||||
*/
|
||||
_notification: function(msg, level, options) {
|
||||
switch (level) {
|
||||
case 'normal':
|
||||
case 'warn':
|
||||
case 'error':
|
||||
Util.Debug("Notification[" + level + "]:" + msg);
|
||||
break;
|
||||
default:
|
||||
Util.Error("Invalid notification level: " + level);
|
||||
return;
|
||||
}
|
||||
|
||||
if (options) {
|
||||
this._onNotification(this, msg, level, options);
|
||||
} else {
|
||||
this._onNotification(this, msg, level);
|
||||
}
|
||||
},
|
||||
|
||||
_handle_message: function () {
|
||||
if (this._sock.rQlen() === 0) {
|
||||
Util.Warn("handle_message called on an empty receive queue");
|
||||
@@ -1130,7 +1158,8 @@
|
||||
|
||||
switch (xvp_msg) {
|
||||
case 0: // XVP_FAIL
|
||||
this._updateState(this._rfb_state, "Operation Failed");
|
||||
Util.Error("Operation Failed");
|
||||
this._notification("XVP Operation Failed", 'error');
|
||||
break;
|
||||
case 1: // XVP_INIT
|
||||
this._rfb_xvp_ver = xvp_ver;
|
||||
@@ -1322,6 +1351,7 @@
|
||||
|
||||
// Callback functions
|
||||
['onUpdateState', 'rw', 'func'], // onUpdateState(rfb, state, oldstate, statusMsg): RFB state update/change
|
||||
['onNotification', 'rw', 'func'], // onNotification(rfb, msg, level, options): notification for the UI
|
||||
['onPasswordRequired', 'rw', 'func'], // onPasswordRequired(rfb, msg): VNC password is required
|
||||
['onClipboard', 'rw', 'func'], // onClipboard(rfb, text): RFB clipboard contents received
|
||||
['onBell', 'rw', 'func'], // onBell(rfb): RFB Bell message received
|
||||
@@ -2275,7 +2305,8 @@
|
||||
msg = "Unknown reason";
|
||||
break;
|
||||
}
|
||||
Util.Info("Server did not accept the resize request: " + msg);
|
||||
this._notification("Server did not accept the resize request: "
|
||||
+ msg, 'normal');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user