Пример #1
0
        /// <summary>
        /// Opens the local server for local coyote test processes to connect to.
        /// </summary>
        internal async Task RunServerAsync()
        {
            this.WriteLine("Starting telemetry server...");
            var resolver = new SmartSocketTypeResolver(typeof(TelemetryEvent), typeof(TelemetryMetric));
            var server   = SmartSocketServer.StartServer(TelemetryServerEndPoint, resolver, null /* localhost only */, UdpGroupAddress, UdpGroupPort);

            server.ClientConnected    += this.OnClientConnected;
            server.ClientDisconnected += this.OnClientDisconnected;
            this.Server = server;

            // Here we see the reason for this entire class.  In order to allow coyote.exe to terminate quickly
            // and not lose telemetry messages, we have to wait a bit to allow the App Insights cloud messages
            // to get through, then we can safely terminate this server process.
            while (this.Telemetry != null && this.LastEvent + this.ServerTerminateDelay > DateTime.Now)
            {
                await Task.Delay((int)this.ServerTerminateDelay.TotalMilliseconds);

                if (this.PendingEvents)
                {
                    this.WriteLine("Flushing telemetry...");
                    this.PendingEvents = false;
                    this.Telemetry.Flush();
                    this.LastEvent = DateTime.Now; // go around again to give flush time to finish.
                }
            }

            this.Telemetry = null;
        }
        /// <summary>
        /// Opens the local server for TestingProcesses to connect to.
        /// If we are not running anything out of process then this does nothing.
        /// </summary>
        private void StartServer()
        {
            if (!this.IsRunOutOfProcess)
            {
                return;
            }

            var resolver = new SmartSocketTypeResolver(typeof(BugFoundMessage),
                                                       typeof(TestReportMessage),
                                                       typeof(TestServerMessage),
                                                       typeof(TestProgressMessage),
                                                       typeof(TestTraceMessage),
                                                       typeof(TestReport),
                                                       typeof(CoverageInfo),
                                                       typeof(Configuration));
            var server = SmartSocketServer.StartServer(this.Configuration.TestingSchedulerEndPoint, resolver, this.Configuration.TestingSchedulerIpAddress);

            server.ClientConnected    += this.OnClientConnected;
            server.ClientDisconnected += this.OnClientDisconnected;
            server.BackChannelOpened  += this.OnBackChannelOpened;

            // pass this along to the TestingProcesses.
            this.Configuration.TestingSchedulerIpAddress = server.EndPoint.ToString();

            IO.Debug.WriteLine($"... Server listening on '{server.EndPoint}'");

            this.Server = server;
        }
Пример #3
0
        void Start()
        {
            SmartSocketServer server = SmartSocketServer.StartServer(Name, new SmartSocketTypeResolver(typeof(ServerMessage), typeof(ClientMessage)));

            server.ClientConnected    += OnClientConnected;
            server.ClientDisconnected += OnClientDisconnected;
            server.BackChannelOpened  += OnBackChannelOpened;

            Console.WriteLine("Press any key to terminate...");
            Console.ReadLine();
        }