/// <summary>Tries to connect to a server.</summary> /// <param name="conData">Set the connection information properties as needed. /// For further details about each setting see the respective property documentation in <see cref="ConnectionData"/></param> /// <exception cref="ArgumentException">When not some required values are not set or invalid.</exception> /// <exception cref="Ts3Exception">When the connection could not be established.</exception> public override void Connect(ConnectionData conData) { if (!(conData is ConnectionDataFull conDataFull)) { throw new ArgumentException($"Use the {nameof(ConnectionDataFull)} deriverate to connect with the full client.", nameof(conData)); } try { HidePing = File.Exists("noping"); } catch (Exception) { } Console.WriteLine("Hidden Ping: {0}", HidePing); if (conDataFull.Identity == null) { throw new ArgumentNullException(nameof(conDataFull.Identity)); } if (conDataFull.VersionSign == null) { throw new ArgumentNullException(nameof(conDataFull.VersionSign)); } connectionDataFull = conDataFull; ConnectionData = conData; Disconnect(); if (!TsDnsResolver.TryResolve(conData.Address, out remoteAddress)) { throw new Ts3Exception("Could not read or resolve address."); } lock (statusLock) { returnCode = 0; status = Ts3ClientStatus.Connecting; context = new ConnectionContext { WasExit = false }; VersionSign = conDataFull.VersionSign; ts3Crypt.Reset(); ts3Crypt.Identity = conDataFull.Identity; packetHandler.Connect(remoteAddress); dispatcher.Init(NetworkLoop, InvokeEvent, context); } dispatcher.EnterEventLoop(); }