Esempio n. 1
0
        public override async void OnTick()
        {
            try
            {
                if (TeamSpeak3Telnet.TS3_CLIENT == null || !TeamSpeak3Telnet.TS3_CLIENT.IsConnected)
                {
                    TeamSpeak3Telnet.SetupTelnetClient(_settings.ApiKey);
                    if (TeamSpeak3Telnet.TS3_CLIENT == null)
                    {
                        return;
                    }
                }

                var clientId = TeamSpeak3Telnet.GetClientId();
                if (clientId == -1)
                {
                    TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                    TeamSpeak3Telnet.TS3_CLIENT = null;
                    return;
                }

                var outputMuteStatus = TeamSpeak3Telnet.GetOutputMuteStatus(clientId);
                if (outputMuteStatus == _savedSatus)
                {
                    await SetOutputStatusState(outputMuteStatus);

                    return;
                }

                switch (outputMuteStatus)
                {
                case -1:
                    return;

                case 0:
                    await SetOutputStatusState();

                    break;

                case 1:
                    await SetOutputStatusState(1);

                    break;
                }

                _savedSatus = outputMuteStatus;
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
                await SetOutputStatusState();
            }
        }
Esempio n. 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();
            }
        }