Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _connect(view, displayUrl) {
if (this._rfbClient) {
console.log('An RFB client already appears to be connected, returning')
return
}
console.log('Creating RFB connection')
this._rfbClient = new RFB(view, displayUrl)
this._rfbClient.addEventListener('connect', (ev) => { this._connectedToRFBServer(ev) })
this._rfbClient.addEventListener('disconnect', (ev) => { this._disconnectedFromRFBServer(ev) })
this._rfbClient.addEventListener('clipboard', (ev) => { this._handleRecvClipboard(ev) })
this._rfbClient.resizeSession = true
this._rfbClient.scaleViewport = true
}
$onInit() {
this.connected = false;
this.status = STATUS_CONNECTING;
const rfbUrl = `wss://${this.host}:${this.port}/`;
const rfbConfig = {
credentials: {
password: this.password,
},
wsProtocols: ['binary', 'base64'],
shared: true,
repeaterID: '',
};
this.rfb = new RFB(
document.getElementById('noVNC_screen'),
rfbUrl,
rfbConfig,
);
this.rfb.addEventListener('connect', () => {
this.rfb.background = '#000';
this.$timeout(() => {
this.connected = true;
this.status = STATUS_CONNECTED;
});
});
this.rfb.addEventListener('disconnect', () => {
this.$timeout(() => {
this.connected = false;