Refact. Flutter web, peer cards (#7525)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-03-27 11:26:29 +08:00
committed by GitHub
parent 8ecc107c06
commit d7137990b9
5 changed files with 266 additions and 133 deletions

View File

@@ -453,6 +453,16 @@ export default class Connection {
}
}
changePreferCodec() {
const supported_decoding = message.SupportedDecoding.fromPartial({
ability_vp9: 1,
ability_h264: 1,
});
const option = message.OptionMessage.fromPartial({ supported_decoding });
const misc = message.Misc.fromPartial({ option });
this._ws?.sendMessage({ misc });
}
async reconnect() {
this.close();
await this.start(this._id);
@@ -549,7 +559,15 @@ export default class Connection {
handlePeerInfo(pi: message.PeerInfo) {
localStorage.setItem('last_remote_id', this._id);
this._peerInfo = pi;
if (pi.current_display > pi.displays.length) {
pi.current_display = 0;
}
if (globals.getVersionNumber(pi.version) < globals.getVersionNumber("1.1.10")) {
this.setPermission("restart", false);
}
if (pi.displays.length == 0) {
this.setOption("info", pi);
globals.pushEvent("update_privacy_mode", {});
this.msgbox("error", "Remote Error", "No Display");
return;
}
@@ -559,6 +577,7 @@ export default class Connection {
if (p) this.inputOsPassword(p);
const username = this.getOption("info")?.username;
if (username && !pi.username) pi.username = username;
globals.pushEvent("update_privacy_mode", {});
this.setOption("info", pi);
if (this.getRemember()) {
if (this._password?.length) {
@@ -573,6 +592,10 @@ export default class Connection {
}
}
setPermission(name: string, value: Boolean) {
globals.pushEvent("permission", { [name]: value });
}
shouldAutoLogin(): string {
const l = this.getOption("lock-after-session-end");
const a = !!this.getOption("auto-login");
@@ -608,7 +631,7 @@ export default class Connection {
default:
return;
}
globals.pushEvent("permission", { [name]: p.enabled });
this.setPermission(name, p.enabled);
} else if (misc.switch_display) {
this.loadVideoDecoder();
globals.pushEvent("switch_display", misc.switch_display);