Remove RFB.notification()
This interface was a band aid for poor design. The two cases where it was used was replaced by logging.
This commit is contained in:
+1
-18
@@ -52,10 +52,6 @@ function enableUI() {
|
||||
encoding = VNC_frame_encoding;
|
||||
}
|
||||
|
||||
const notification = function (rfb, mesg, level, options) {
|
||||
document.getElementById('VNC_status').textContent = mesg;
|
||||
}
|
||||
|
||||
function IterationPlayer (iterations, frames, encoding) {
|
||||
this._iterations = iterations;
|
||||
|
||||
@@ -72,7 +68,6 @@ function IterationPlayer (iterations, frames, encoding) {
|
||||
this.onfinish = function() {};
|
||||
this.oniterationfinish = function() {};
|
||||
this.rfbdisconnected = function() {};
|
||||
this.rfbnotification = function() {};
|
||||
}
|
||||
|
||||
IterationPlayer.prototype = {
|
||||
@@ -87,7 +82,7 @@ IterationPlayer.prototype = {
|
||||
},
|
||||
|
||||
_nextIteration: function () {
|
||||
const player = new RecordingPlayer(this._frames, this._encoding, this._disconnected.bind(this), this._notification.bind(this));
|
||||
const player = new RecordingPlayer(this._frames, this._encoding, this._disconnected.bind(this));
|
||||
player.onfinish = this._iterationFinish.bind(this);
|
||||
|
||||
if (this._state !== 'running') { return; }
|
||||
@@ -131,15 +126,6 @@ IterationPlayer.prototype = {
|
||||
|
||||
this.onrfbdisconnected(evt);
|
||||
},
|
||||
|
||||
_notification: function (rfb, msg, level, options) {
|
||||
var evt = new Event('rfbnotification');
|
||||
evt.message = msg;
|
||||
evt.level = level;
|
||||
evt.options = options;
|
||||
|
||||
this.onrfbnotification(evt);
|
||||
},
|
||||
};
|
||||
|
||||
function start() {
|
||||
@@ -167,9 +153,6 @@ function start() {
|
||||
message(`noVNC sent disconnected during iteration ${evt.iteration} frame ${evt.frame}`);
|
||||
}
|
||||
};
|
||||
player.onrfbnotification = function (evt) {
|
||||
document.getElementById('VNC_status').textContent = evt.message;
|
||||
};
|
||||
player.onfinish = function (evt) {
|
||||
const iterTime = parseInt(evt.duration / evt.iterations, 10);
|
||||
message(`${evt.iterations} iterations took ${evt.duration}ms (average ${iterTime}ms / iteration)`);
|
||||
|
||||
+1
-3
@@ -44,12 +44,11 @@ if (setImmediate === undefined) {
|
||||
window.addEventListener("message", _onMessage);
|
||||
}
|
||||
|
||||
export default function RecordingPlayer (frames, encoding, disconnected, notification) {
|
||||
export default function RecordingPlayer (frames, encoding, disconnected) {
|
||||
this._frames = frames;
|
||||
this._encoding = encoding;
|
||||
|
||||
this._disconnected = disconnected;
|
||||
this._notification = notification;
|
||||
|
||||
if (this._encoding === undefined) {
|
||||
let frame = this._frames[0];
|
||||
@@ -80,7 +79,6 @@ RecordingPlayer.prototype = {
|
||||
this._rfb = new RFB(document.getElementById('VNC_canvas'), 'wss://test');
|
||||
this._rfb.viewOnly = true;
|
||||
this._rfb.ondisconnected = this._handleDisconnect.bind(this);
|
||||
this._rfb.onnotification = this._notification;
|
||||
this._enablePlaybackMode();
|
||||
|
||||
// reset the frame index and timer
|
||||
|
||||
@@ -400,27 +400,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#_notification', function () {
|
||||
var client;
|
||||
beforeEach(function () { client = make_rfb(); });
|
||||
|
||||
it('should call the notification callback', function () {
|
||||
var spy = sinon.spy();
|
||||
client.addEventListener("notification", spy);
|
||||
client._notification('notify!', 'warn');
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0][0].detail.message).to.equal('notify!');
|
||||
expect(spy.args[0][0].detail.level).to.equal('warn');
|
||||
});
|
||||
|
||||
it('should not call the notification callback when level is invalid', function () {
|
||||
var spy = sinon.spy();
|
||||
client.addEventListener("notification", spy);
|
||||
client._notification('notify!', 'invalid');
|
||||
expect(spy).to.not.have.been.called;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Connection States', function () {
|
||||
@@ -1589,14 +1568,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||
});
|
||||
|
||||
describe('XVP Message Handling', function () {
|
||||
it('should send a notification on XVP_FAIL', function () {
|
||||
var spy = sinon.spy();
|
||||
client.addEventListener("notification", spy);
|
||||
client._sock._websocket._receive_data(new Uint8Array([250, 0, 10, 0]));
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0][0].detail.message).to.equal('XVP Operation Failed');
|
||||
});
|
||||
|
||||
it('should set the XVP version and fire the callback with the version on XVP_INIT', function () {
|
||||
var spy = sinon.spy();
|
||||
client.addEventListener("capabilities", spy);
|
||||
|
||||
@@ -85,10 +85,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
notification = function (rfb, mesg, level, options) {
|
||||
document.getElementById('VNC_status').textContent = mesg;
|
||||
}
|
||||
|
||||
function do_test() {
|
||||
document.getElementById('startButton').value = "Running";
|
||||
document.getElementById('startButton').disabled = true;
|
||||
|
||||
Reference in New Issue
Block a user