Start() публичный Метод

public Start ( ) : void
Результат void
Пример #1
0
 IEnumerator RunServer()
 {
     UnityEngine.Debug.Log("starting server thread");
     _server = new ServerThread();
     _server.Start();
     yield return(null);
 }
Пример #2
0
        public void ListenTest()
        {
            var t = new ServerThread();

            t.Start();
            Assert.Fail();
        }
Пример #3
0
 static void Main(string[] args)
 {
     thread = new ServerThread(8989);
     thread.Start();
     Console.ReadKey();
     thread.Stop();
 }
Пример #4
0
Файл: test.cs Проект: mono/gert
	static void RunTest ()
	{
		// Start the server thread
		ServerThread serverThread = new ServerThread ();
		serverThread.Start ();

		// Create the client
		HttpWebRequest rq = (HttpWebRequest) WebRequest.Create ("http://" + IPAddress.Loopback.ToString () + ":54321");
		rq.ProtocolVersion = HttpVersion.Version11;
		rq.KeepAlive = false;

		// Get the response
		HttpWebResponse rsp = (HttpWebResponse) rq.GetResponse ();
		ASCIIEncoding enc = new ASCIIEncoding ();

		StringBuilder result = new StringBuilder ();

		// Stream the body in 1 byte at a time
		byte [] bytearr = new byte [1];
		Stream st = rsp.GetResponseStream ();
		while (true) {
			int b = st.Read (bytearr, 0, 1);
			if (b == 0) {
				break;
			}

			result.Append (enc.GetString (bytearr));
		}

		Assert.AreEqual ("012345670123456789abcdefabcdefghijklmnopqrstuvwxyz",
			result.ToString (), "#1");
	}
Пример #5
0
        static void Main(string[] args)
        {
            Trace.Listeners[0].TraceOutputOptions = TraceOptions.None;
            Trace.UseGlobalLock = true;

            var server = new ServerThread();

            server.Start();

            System.Diagnostics.Process.Start("http://localhost:65125/index.html");


            while (true)
            {
                if (server.test != null)
                {
                    server.test.Send("aaaa");
                }
                System.Threading.Thread.Sleep(1000);
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(errorFileName));
            Trace.AutoFlush = true;

            if (args.Any(c => c.ToLower() == "/armobs"))
            {
                if (args.Length == 1)
                {
                    var obs32List = Process.GetProcessesByName("obs32");
                    var obs64List = Process.GetProcessesByName("obs64");
                    if (obs32List.Length == 0 && obs64List.Length == 0)
                    {
                        //No OBS found. Cancel operation.
                        File.Delete(OBSUtils.obswszip);
                        return;
                    }
                    List <Process> obsProcesses = new List <Process>();
                    obsProcesses.AddRange(obs32List);
                    obsProcesses.AddRange(obs64List);

                    if (obsProcesses.Count != 1)
                    {
                        //Multiple OBS instances found. Cancel operation.
                        File.Delete(OBSUtils.obswszip);
                        return;
                    }
                    var obsProcess = obsProcesses.First();

                    string path        = OBSUtils.GetProcessPath(obsProcess.Id);
                    string zipTempPath = Path.GetFileNameWithoutExtension(OBSUtils.obswszip);
                    OBSUtils.ExtractZip(OBSUtils.obswszip, zipTempPath);

                    OBSUtils.DirectoryCopy(zipTempPath, OBSUtils.GetPathFromOBSExecutable(path), true);
                    File.Delete(OBSUtils.obswszip);
                    Directory.Delete(zipTempPath, true);

                    var obsGlobalFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "obs-studio", "global.ini");
                    if (File.Exists(obsGlobalFilePath) && !File.ReadAllText(obsGlobalFilePath).Contains("[WebsocketAPI]"))
                    {
                        while (!obsProcess.HasExited)
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine("OBS plugin install completed!");
                            sb.AppendLine("");
                            sb.AppendLine("Please close OBS and click OK to apply the final touches.");
                            MessageBox.Show(sb.ToString());
                        }

                        using (StreamWriter outputFile = new StreamWriter(obsGlobalFilePath)) {
                            outputFile.WriteLine("");
                            outputFile.WriteLine("[WebsocketAPI]");
                            outputFile.WriteLine("ServerPort=4444");
                            outputFile.WriteLine("DebugEnabled=false");
                            outputFile.WriteLine("AlertsEnabled=false");
                            outputFile.WriteLine("AuthRequired=false");
                        }

                        bool shouldRepeat = true;
                        while (shouldRepeat)
                        {
                            var obs32List2 = Process.GetProcessesByName("obs32");
                            var obs64List2 = Process.GetProcessesByName("obs64");

                            shouldRepeat = obs32List2.Length == 0 && obs64List2.Length == 0;
                            if (!shouldRepeat)
                            {
                                break;
                            }

                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine("OBS plugin install successfully!");
                            sb.AppendLine("");
                            sb.AppendLine("Please open OBS and click OK to continue to the app.");
                            MessageBox.Show(sb.ToString());
                        }
                    }

                    return;
                }
            }

#if FORCE_SILENCE
            Silent = true;
#else
            Silent = args.Any(c => c.ToLower() == "/s");
#endif
            errorText = $"An error occured! And it was saved to a file called {errorFileName}." + Environment.NewLine + "Please send this to the developer of the application.";

            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            ApplicationSettingsManager.LoadSettings();
            DevicePersistManager.LoadDevices();


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (ApplicationSettingsManager.Settings.FirstRun)
            {
                FirstSetupForm firstRunForm = new FirstSetupForm();
                Application.Run(firstRunForm);
                if (!firstRunForm.FinishedSetup)
                {
                    return;
                }
            }

            OBSUtils.PrepareOBSIntegration();


            NetworkChange.NetworkAddressChanged      += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAddressChanged;

            ServerThread = new ServerThread();
            ServerThread.Start();

            Application.Run(new MainForm());

            OBSUtils.Disconnect();

            ServerThread.Stop();
            NetworkChange.NetworkAddressChanged      -= NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged -= NetworkChange_NetworkAddressChanged;
            ApplicationSettingsManager.SaveSettings();
            DevicePersistManager.SaveDevices();
            Trace.Flush();
        }
Пример #7
0
 private static void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
 {
     ServerThread.Stop();
     ServerThread = new ServerThread();
     ServerThread.Start();
 }
Пример #8
0
 public void Restart()
 {
     st.Stop();
     st.Start();
 }
Пример #9
0
 public void Rebind()
 {
     st.Stop();
     st = new ServerThread(ip, port);
     st.Start();
 }
Пример #10
0
 void Start()
 {
     st = new ServerThread(ip, port);
     st.Start();
     parser = this.GetComponent <CommandParser> ();
 }