private void HandleServerMessage(TestServerMessage tsr) { if (tsr.Stop) { // Server wants us to stop! if (this.Configuration.IsVerbose) { this.StdOut.WriteLine($"... ### Client {this.Configuration.TestingProcessId} is being told to stop!"); } this.TestingEngine.Stop(); this.Terminating = true; } }
private async void CleanupTestProcesses(uint bugProcessId, int maxWait = 60000) { try { string serverName = this.Configuration.TestingSchedulerEndPoint; var stopRequest = new TestServerMessage("TestServerMessage", serverName) { Stop = true }; var snapshot = new Dictionary <uint, Process>(this.TestingProcesses); foreach (var testingProcess in snapshot) { if (testingProcess.Key != bugProcessId) { string name = "CoyoteTestingProcess." + testingProcess.Key; lock (this.Terminating) { this.Terminating.Add(name); } if (this.TestingProcessChannels.TryGetValue(name, out SmartSocketClient client) && client.BackChannel != null) { // use the back channel to stop the client immediately, which will trigger client // to also send us their TestReport (on the regular channel). await client.BackChannel.SendAsync(stopRequest); } } } await this.WaitForParallelTestReports(maxWait); } catch (Exception ex) { Console.WriteLine($"... Exception: {ex.Message}"); } }
private async void OnBackChannelOpened(object sender, SmartSocketClient e) { // this is the socket we can use to communicate directly to the client... it will be // available as the "BackChannel" property on the associated client socket. // But if we've already asked this client to terminate then tell it to stop. SocketMessage response = new TestServerMessage("ok", this.Configuration.TestingSchedulerEndPoint); TestServerMessage message = null; lock (this.Terminating) { if (this.Terminating.Contains(e.Name)) { message = new TestServerMessage("ok", this.Configuration.TestingSchedulerEndPoint) { Stop = true }; } } if (message != null) { await e.BackChannel.SendAsync(message); } }