Ejemplo n.º 1
0
        public override async void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");

            try
            {
                if (TeamSpeak3Telnet.TS3_CLIENT == null || !TeamSpeak3Telnet.TS3_CLIENT.IsConnected)
                {
                    TeamSpeak3Telnet.SetupTelnetClient(_settings.ApiKey);
                    if (TeamSpeak3Telnet.TS3_CLIENT == null)
                    {
                        return;
                    }
                }

                if (payload.IsInMultiAction)
                {
                    await ToggleMicMuteLocally((int)payload.UserDesiredState);
                }
                else
                {
                    await ToggleMicMuteLocally(payload.State == 1? 0 : 1);
                }
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
                await SetInputStatusStateLocally();
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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 inputMuteStatus = TeamSpeak3Telnet.GetInputMuteStatus(clientId);
                if (inputMuteStatus == _savedSatus)
                {
                    await SetInputStatusState(inputMuteStatus);

                    return;
                }

                switch (inputMuteStatus)
                {
                case -1:
                    return;

                case 0:
                    await SetInputStatusState();

                    break;

                case 1:
                    await SetInputStatusState(1);

                    break;
                }

                _savedSatus = inputMuteStatus;
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
                await SetInputStatusState();
            }
        }
Ejemplo n.º 4
0
        private async Task ToggleMicMuteLocally(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.GetInputMuteStatusLocally(clientId);
                }
                else
                {
                    outputMuteStatus = desiredState == 1 ? 0 : 1;
                }

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

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

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

                if (!setOutputMuteStatus)
                {
                    return;
                }
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
                await SetInputStatusStateLocally();
            }
        }
        private void ChannelSwitch()
        {
            try
            {
                var clientId = TeamSpeak3Telnet.GetClientId();
                if (clientId == -1)
                {
                    TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                    TeamSpeak3Telnet.TS3_CLIENT = null;
                    return;
                }

                TeamSpeak3Telnet.ChannelSwitch(_settings.ChannelName, clientId);
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
            }
        }
        public override async void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");

            try
            {
                if (TeamSpeak3Telnet.TS3_CLIENT == null || !TeamSpeak3Telnet.TS3_CLIENT.IsConnected)
                {
                    TeamSpeak3Telnet.SetupTelnetClient(_settings.ApiKey);
                    if (TeamSpeak3Telnet.TS3_CLIENT == null)
                    {
                        return;
                    }
                }

                ChannelSwitch();
            }
            catch (Exception)
            {
                TeamSpeak3Telnet.TS3_CLIENT?.Dispose();
                TeamSpeak3Telnet.TS3_CLIENT = null;
            }
        }