private void OnSearchAction(string obj, ICommunication communication) { if (isConnected) { _errorMsg = "Error: " + "This command does not exist or isn't enabled at this time"; return; } _OutputWrapper.WriteOutput(0, 1, "Searching...", ConsoleColor.DarkGray); if (isConnected) { return; } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _UdpListener.StartListening(); while (stopwatch.ElapsedMilliseconds < 10000) { if (_UdpListener._DataList.Count > 0) { communication.AddPackage(_UdpListener._DataList.First()); _UdpListener._DataList.RemoveAt(0); } } stopwatch.Stop(); _UdpListener.StopListening(); Searched = true; }
public void OnSearchAction(string input, ICommunication communication) { _outputWrapper.WriteOutput(0, 1, "Searching...", ConsoleColor.DarkGray); var stopwatch = new Stopwatch(); stopwatch.Start(); _udpListener._closed = false; _udpListener.SendRequest(); while (stopwatch.ElapsedMilliseconds < 3000) { if (_udpListener._dataList.Count > 0) { communication.AddPackage(_udpListener._dataList.First()); _udpListener._dataList.RemoveAt(0); } } stopwatch.Stop(); _udpListener.StopListening(); _outputWrapper.Clear(); _searched = true; _declined = false; _inputView.ViewEnabled = true; if (_actionHandler._serverTable.Length != 0) { _inputView.SetInputLine("Enter the server number you want to connect to.", 49); } }