Reduced client update command spam as well reduced the overall client join commands (Fixing #147)
This commit is contained in:
parent
8be3943d00
commit
d3d11700ce
1 changed files with 18 additions and 14 deletions
|
@ -175,7 +175,7 @@ export class ConnectionHandler {
|
||||||
|
|
||||||
lastChannelCodecWarned: -1
|
lastChannelCodecWarned: -1
|
||||||
};
|
};
|
||||||
private clientStatusUnsync = false;
|
private clientStatusSync = false;
|
||||||
|
|
||||||
private inputHardwareState: InputHardwareState = InputHardwareState.MISSING;
|
private inputHardwareState: InputHardwareState = InputHardwareState.MISSING;
|
||||||
|
|
||||||
|
@ -368,8 +368,11 @@ export class ConnectionHandler {
|
||||||
this.sound.play(Sound.CONNECTION_CONNECTED);
|
this.sound.play(Sound.CONNECTION_CONNECTED);
|
||||||
|
|
||||||
this.permissions.requestPermissionList();
|
this.permissions.requestPermissionList();
|
||||||
|
/*
|
||||||
|
There is no need to request the server groups since they must be send by the server
|
||||||
if(this.groups.serverGroups.length == 0)
|
if(this.groups.serverGroups.length == 0)
|
||||||
this.groups.requestGroups();
|
this.groups.requestGroups();
|
||||||
|
*/
|
||||||
|
|
||||||
this.settings.setServer(this.channelTree.server.properties.virtualserver_unique_identifier);
|
this.settings.setServer(this.channelTree.server.properties.virtualserver_unique_identifier);
|
||||||
|
|
||||||
|
@ -746,24 +749,25 @@ export class ConnectionHandler {
|
||||||
/* update our owns client properties */
|
/* update our owns client properties */
|
||||||
{
|
{
|
||||||
const currentClientProperties = this.getClient().properties;
|
const currentClientProperties = this.getClient().properties;
|
||||||
for(const key of Object.keys(localClientUpdates)) {
|
if(this.clientStatusSync) {
|
||||||
if(currentClientProperties[key] === localClientUpdates[key] && !this.clientStatusUnsync)
|
for(const key of Object.keys(localClientUpdates)) {
|
||||||
delete localClientUpdates[key];
|
if(currentClientProperties[key] === localClientUpdates[key])
|
||||||
|
delete localClientUpdates[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Object.keys(localClientUpdates).length > 0) {
|
if(Object.keys(localClientUpdates).length > 0) {
|
||||||
this.serverConnection.send_command("clientupdate", localClientUpdates).then(() => {
|
/* directly update all update locally so we don't send updates twice */
|
||||||
this.clientStatusUnsync = false;
|
const updates = [];
|
||||||
}).catch(error => {
|
for(const key of Object.keys(localClientUpdates))
|
||||||
|
updates.push({ key: key, value: localClientUpdates[key] ? "1" : "0" });
|
||||||
|
this.getClient().updateVariables(...updates);
|
||||||
|
|
||||||
|
this.clientStatusSync = true;
|
||||||
|
this.serverConnection.send_command("clientupdate", localClientUpdates).catch(error => {
|
||||||
log.warn(LogCategory.GENERAL, tr("Failed to update client audio hardware properties. Error: %o"), error);
|
log.warn(LogCategory.GENERAL, tr("Failed to update client audio hardware properties. Error: %o"), error);
|
||||||
this.log.log(EventType.ERROR_CUSTOM, { message: tr("Failed to update audio hardware properties.") });
|
this.log.log(EventType.ERROR_CUSTOM, { message: tr("Failed to update audio hardware properties.") });
|
||||||
this.clientStatusUnsync = true;
|
this.clientStatusSync = false;
|
||||||
|
|
||||||
/* Update these properties anyways (for case the server fails to handle the command) */
|
|
||||||
const updates = [];
|
|
||||||
for(const key of Object.keys(localClientUpdates))
|
|
||||||
updates.push({ key: key, value: localClientUpdates[key] ? "1" : "0" });
|
|
||||||
this.getClient().updateVariables(...updates);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue