diff --git a/ts3-client/core/src/main/java/com/ts3client/net/TeamspeakConnection.java b/ts3-client/core/src/main/java/com/ts3client/net/TeamspeakConnection.java index 9cbc77a..c6107a0 100644 --- a/ts3-client/core/src/main/java/com/ts3client/net/TeamspeakConnection.java +++ b/ts3-client/core/src/main/java/com/ts3client/net/TeamspeakConnection.java @@ -472,8 +472,16 @@ public final class TeamspeakConnection implements TS3Listener { } private void pushSelfFlags() { + if (microphone == null || playback == null) return; + boolean micMuted = microphone.isMuted(); + boolean deaf = playback.isDeafened(); + updateSelf(self -> { + self.inputMuted = micMuted; + self.outputMuted = deaf; + }); + // Best-effort: publish input/output muted flags to the server so others see them. - if (client == null || !connected || microphone == null || playback == null) return; + if (client == null || !connected) return; try { java.util.Map props = new java.util.HashMap<>(); props.put("client_input_muted", microphone.isMuted() ? "1" : "0"); @@ -573,6 +581,7 @@ public final class TeamspeakConnection implements TS3Listener { public void setAway(boolean away, String message) { sound(away ? SoundEvent.STATUS_SET_AWAY : SoundEvent.STATUS_SET_PRESENT); + updateSelf(self -> self.away = away); selfUpdate(cmd -> { cmd.add(new CommandSingleParameter("client_away", away ? "1" : "0")); cmd.add(new CommandSingleParameter("client_away_message", away && message != null ? message : "")); @@ -580,11 +589,24 @@ public final class TeamspeakConnection implements TS3Listener { } public void setChannelCommander(boolean commander) { + updateSelf(self -> self.channelCommander = commander); selfUpdate(cmd -> cmd.add(new CommandSingleParameter("client_is_channel_commander", commander ? "1" : "0")), "Channel commander update failed"); } + /** + * Applies a change of our own state to the local model. The server sends + * {@code notifyclientupdated} to the other clients only, so without this + * our own row would keep its old icons until something else refreshed it. + */ + private void updateSelf(java.util.function.Consumer change) { + ClientEntry self = model.getClient(selfClientId); + if (self == null) return; + change.accept(self); + ui.onModelChanged(); + } + /** Sends a {@code clientupdate} for the local client on a background thread. */ private void selfUpdate(java.util.function.Consumer fill, String errorLabel) { new Thread(() -> {