Exemple #1
0
        private async Task ToggleAwayStatus(int desiredState = -1)
        {
            try
            {
                var clientId = TeamSpeak3Telnet.GetClientId();
                if (clientId == -1)
                {
                    TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                    TeamSpeak3Telnet.TS3_CLIENT = null;
                    return;
                }

                int awayStatus;
                if (desiredState == -1)
                {
                    awayStatus = TeamSpeak3Telnet.GetAwayStatus(clientId);
                }
                else
                {
                    awayStatus = desiredState == 1 ? 0 : 1;
                }

                var setAwayStatus = false;
                switch (awayStatus)
                {
                case -1:
                    return;

                case 0:
                    TeamSpeak3Telnet.SetInputMuteStatus(1);
                    TeamSpeak3Telnet.SetOutputMuteStatus(1);
                    setAwayStatus = TeamSpeak3Telnet.SetAwayStatus(1);
                    if (_settings.AwayStatusMessage.Length > 0)
                    {
                        TeamSpeak3Telnet.SetAwayMessage(_settings.AwayStatusMessage);
                    }
                    break;

                case 1:
                    TeamSpeak3Telnet.SetInputMuteStatus(0);
                    TeamSpeak3Telnet.SetOutputMuteStatus(0);
                    setAwayStatus = TeamSpeak3Telnet.SetAwayStatus(0);
                    break;
                }

                if (!setAwayStatus)
                {
                    return;
                }
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
                await SetAwayStatusState();
            }
        }
Exemple #2
0
        private async Task ToggleOutputMute(int desiredState = -1)
        {
            try
            {
                var clientId = TeamSpeak3Telnet.GetClientId();
                if (clientId == -1)
                {
                    TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                    TeamSpeak3Telnet.TS3_CLIENT = null;
                    return;
                }

                int outputMuteStatus;
                if (desiredState == -1)
                {
                    outputMuteStatus = TeamSpeak3Telnet.GetOutputMuteStatus(clientId);
                }
                else
                {
                    outputMuteStatus = desiredState == 1 ? 0 : 1;
                }

                var setOutputMuteStatus = false;
                switch (outputMuteStatus)
                {
                case -1:
                    return;

                case 0:
                    setOutputMuteStatus = TeamSpeak3Telnet.SetOutputMuteStatus(1);
                    break;

                case 1:
                    setOutputMuteStatus = TeamSpeak3Telnet.SetOutputMuteStatus(0);
                    break;
                }

                if (!setOutputMuteStatus)
                {
                    return;
                }
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
                await SetOutputStatusState();
            }
        }