private void TsFullClient_OnConnected(object sender, EventArgs e)
 {
     StopReconnectTickWorker();
     reconnectCounter = 0;
     lastReconnect    = null;
     OnBotConnected?.Invoke(this, EventArgs.Empty);
 }
Exemple #2
0
        private async Task ConnectClient()
        {
            if (identity is null)
            {
                throw new InvalidOperationException();
            }

            if (closed)
            {
                return;
            }

            TsVersionSigned?versionSign;

            if (!string.IsNullOrEmpty(config.Connect.ClientVersion.Build.Value))
            {
                var versionConf = config.Connect.ClientVersion;
                versionSign = TsVersionSigned.TryParse(versionConf.Build, versionConf.Platform.Value, versionConf.Sign);

                if (versionSign is null)
                {
                    Log.Warn("Invalid version sign, falling back to unknown :P");
                    versionSign = TsVersionSigned.VER_WIN_3_X_X;
                }
            }
            else if (Tools.IsLinux)
            {
                versionSign = TsVersionSigned.VER_LIN_3_X_X;
            }
            else
            {
                versionSign = TsVersionSigned.VER_WIN_3_X_X;
            }

            var connectionConfig = new ConnectionDataFull(config.Connect.Address, identity,
                                                          versionSign: versionSign,
                                                          username: config.Connect.Name,
                                                          serverPassword: config.Connect.ServerPassword.Get(),
                                                          defaultChannel: reconnectChannel?.ToPath() ?? config.Connect.Channel,
                                                          defaultChannelPassword: config.Connect.ChannelPassword.Get(),
                                                          logId: id);

            config.SaveWhenExists().UnwrapToLog(Log);

            if (!(await ts3FullClient.Connect(connectionConfig)).GetOk(out var error))
            {
                Log.Error("Could not connect: {0}", error.ErrorFormat());
                return;
            }

            Log.Info("Client connected.");
            reconnectCounter = 0;
            lastReconnect    = null;

            await OnBotConnected.InvokeAsync(this);
        }
Exemple #3
0
 private void TsFullClient_OnConnected(object sender, EventArgs e)
 {
     connecting = false;
     OnBotConnected?.Invoke(this, EventArgs.Empty);
 }