コード例 #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;
        }
コード例 #2
0
        /// <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
 /// <summary>
 /// Closes the local server, if we have one.
 /// </summary>
 private void StopServer()
 {
     if (this.Server != null)
     {
         this.Server.Stop();
         this.Server = null;
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: lovettchris/SmartSockets
        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();
        }