This commit is contained in:
rustdesk 2022-01-31 13:15:18 +08:00
parent c58659c7f9
commit 529b8dc895
2 changed files with 11 additions and 10 deletions

View File

@ -40,14 +40,10 @@ export function pushEvent(name, payload) {
events.push(payload); events.push(payload);
} }
const yuvWorker = new Worker("./yuv.js"); let yuvWorker;
yuvWorker.onmessage = (e) => {
currentFrame = e.data;
}
export function draw(frame) { export function draw(frame) {
yuvWorker.postMessage(frame); if (yuvvWorker) yuvWorker.postMessage(frame);
} }
export function setConn(conn) { export function setConn(conn) {
@ -240,7 +236,7 @@ function getPeersForDart() {
for (const [key, value] of Object.entries(getPeers())) { for (const [key, value] of Object.entries(getPeers())) {
if (!key) continue; if (!key) continue;
const tm = value['tm']; const tm = value['tm'];
const info = values['info']; const info = value['info'];
if (!tm || !info) continue; if (!tm || !info) continue;
peers.push([tm, id, info]); peers.push([tm, id, info]);
} }
@ -282,6 +278,10 @@ function _getByName(name, arg) {
} }
window.init = async () => { window.init = async () => {
yuvWorker = new Worker("./yuv.js");
yuvWorker.onmessage = (e) => {
currentFrame = e.data;
}
loadOpus(() => { }); loadOpus(() => { });
loadVp9(() => { }); loadVp9(() => { });
await initZstd(); await initZstd();

View File

@ -97,13 +97,14 @@ export default class Websock {
}; };
this._websocket.onclose = (e) => { this._websocket.onclose = (e) => {
if (this._status == "open") { if (this._status == "open") {
reject(e); // e.code 1000 means that the connection was closed normally.
reject('Reset by the peer');
} }
this._status = e; this._status = e;
console.error("WebSock.onclose: " + e); console.error("WebSock.onclose: " + e);
this._eventHandlers.close(e); this._eventHandlers.close(e);
}; };
this._websocket.onerror = (e) => { this._websocket.onerror = (e: any) => {
if (!this._status) { if (!this._status) {
reject("Failed to connect to " + this._uri); reject("Failed to connect to " + this._uri);
return; return;
@ -111,7 +112,7 @@ export default class Websock {
this._status = e; this._status = e;
console.error("WebSock.onerror: " + e); console.error("WebSock.onerror: " + e);
this._eventHandlers.error(e); this._eventHandlers.error(e);
reject(e); reject(e['data']);
}; };
}); });
} }