コード例 #1
0
        public void StopServer(RestServerData data)
        {
            RestServer targetRestServer = m_RestServerList.Where(c => c.RestServerData == data).FirstOrDefault();

            if (targetRestServer != null)
            {
                targetRestServer.Close();
                m_RestServerList.Remove(targetRestServer);

                //OnRestServerStopped?.Invoke(this, new OnRestServerStoppedEventArgs(data));
            }
        }
コード例 #2
0
        private RestServer CreateRestServer(RestServerData data)
        {
            try
            {
                RestServer newRestServer = new RestServer(data);

                newRestServer.OnRestServerTrace   += RestServer_OnRestServerTrace;
                newRestServer.OnRestServerStarted += RestServer_OnRestServerStarted;
                newRestServer.OnRestServerStopped += RestServer_OnRestServerStopped;
                m_RestServerList.Add(newRestServer);

                return(newRestServer);
            }
            catch (Exception ex)
            {
                TraceWriteLine(ex.ToString());
            }

            return(null);
        }
コード例 #3
0
        public void StartServer(RestServerData data)
        {
            RestServer targetRestServer = m_RestServerList.Where(c => c.RestServerData == data).FirstOrDefault();

            if (targetRestServer != null)
            {
                try
                {
                    TraceWriteLine($"Rest Server {targetRestServer.Name} initializing run routine");
                    targetRestServer.Run();
                    TraceWriteLine($"Rest Server {targetRestServer.Name} leaving run routine");

                    TraceWriteLine($"Rest server {data.Name} running");

                    //OnRestServerStarted?.Invoke(this, new OnRestServerStartedEventArgs(data));
                }
                catch (Exception ex)
                {
                    TraceWriteLine(ex.ToString());
                }
            }
            else
            {
                targetRestServer = CreateRestServer(data);
                try
                {
                    TraceWriteLine($"Rest Server {targetRestServer.Name} initializing run routine");
                    targetRestServer.Run();
                    TraceWriteLine($"Rest Server {targetRestServer.Name} leaving run routine");

                    TraceWriteLine($"Rest server {data.Name} running");

                    //OnRestServerStarted?.Invoke(this, new OnRestServerStartedEventArgs(data));
                }
                catch (Exception ex)
                {
                    TraceWriteLine(ex.ToString());
                }
            }
        }