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); }
private E <string> ConnectClient() { StopReconnectTickWorker(); if (closed) { return("Bot disposed"); } VersionSign versionSign; if (!string.IsNullOrEmpty(config.Connect.ClientVersion.Build.Value)) { var versionConf = config.Connect.ClientVersion; versionSign = new VersionSign(versionConf.Build, versionConf.Platform.Value, versionConf.Sign); if (!versionSign.CheckValid()) { Log.Warn("Invalid version sign, falling back to unknown :P"); versionSign = VersionSign.VER_WIN_3_X_X; } } else if (Tools.IsLinux) { versionSign = VersionSign.VER_LIN_3_X_X; } else { versionSign = VersionSign.VER_WIN_3_X_X; } try { var connectionConfig = new ConnectionDataFull { Username = config.Connect.Name, ServerPassword = config.Connect.ServerPassword.Get(), Address = config.Connect.Address, Identity = identity, VersionSign = versionSign, DefaultChannel = reconnectChannel?.ToPath() ?? config.Connect.Channel, DefaultChannelPassword = config.Connect.ChannelPassword.Get(), LogId = id, }; config.SaveWhenExists(); ts3FullClient.Connect(connectionConfig); return(R.Ok); } catch (TsException qcex) { Log.Error(qcex, "There is either a problem with your connection configuration, or the bot has not all permissions it needs."); return("Connect error"); } }