static void DebugFile(string file_name, VM vm, int port) { //Console.WriteLine(Environment.CurrentDirectory); Console.WriteLine($"Simple Script {VM.Version}"); try { var func = vm.Parse(File.ReadAllText(file_name), file_name); if (port > 0) { TcpListener serverSocket = new TcpListener(IPAddress.Parse("127.0.0.1"), port); serverSocket.Start(); Console.WriteLine("DebugMode: Listen At {0}", port); var socket = serverSocket.AcceptSocket(); if (socket != null) { Console.WriteLine("DebugMode: Build Connect With {0}", socket.RemoteEndPoint); using (var stream = new NetworkStream(socket)) { var pipe = new SimpleScript.DebugProtocol.NetServerPipe(stream); vm.m_hooker.SetPipeServer(pipe); vm.m_hooker.SetBreakMode(SimpleScript.DebugProtocol.BreakMode.StopForOnce); vm.CallFunction(func); // 测试协程,当成是事件循环也行 Console.WriteLine("Loop update for coroutine, You can close program to Exit!!"); while (true) { CoroutineMgr.Update(); System.Threading.Thread.Sleep(10); } } } } else { var pipe = new IOPipe(); vm.m_hooker.SetPipeServer(pipe); vm.m_hooker.SetBreakMode(SimpleScript.DebugProtocol.BreakMode.StopForOnce); vm.CallFunction(func); // 测试协程,当成是事件循环也行 Console.WriteLine("Loop update for coroutine, You can close program to Exit!!"); while (true) { CoroutineMgr.Update(); System.Threading.Thread.Sleep(10); } } } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Press Any Key To Exit"); Console.ReadKey(true); }
public static void Test() { TestWWW test = new TestWWW(); CoroutineMgr coroutineMgr = new CoroutineMgr(); coroutineMgr.StartCoroutine(test.TestWWWCoroutine()); while (true) { coroutineMgr.Update(); Thread.Sleep(33); } }
static void Main(string[] args) { { //Type[] types = new Type[] { // typeof(bool), // typeof(char), // typeof(byte), typeof(sbyte), // typeof(ushort), typeof(short), // typeof(uint), typeof(int), // typeof(ulong), typeof(long), // typeof(float), typeof(double), //}; //foreach(var t in types) //{ // Console.WriteLine("{0}, {1}", t.IsPrimitive, t.IsValueType); // var obj = Activator.CreateInstance(t, true); // Console.WriteLine("{0}", obj); //} //return; } { SimpleScript.Test.TestManager.RunTest(); //return; } { //ImportCodeGenerate.GenDelegateFactorySource("generate/DelegateFactory.cs", new Type[]{ // typeof(Func<int,int>), // typeof(Action), //}); //Console.WriteLine(typeof(Int64).IsPrimitive); VM vm = new VM(); LibBase.Register(vm); LibCoroutine.Register(vm); vm.ComileFile("test.oms", "test.omsc"); var pipe = new IOPipe(); vm.m_hooker.SetPipeServer(pipe); vm.m_hooker.SetBreakMode(SimpleScript.DebugProtocol.BreakMode.StopForOnce); vm.DoFile("test.omsc"); // 测试协程,当成是事件循环也行 Console.Write("Start update coroutine!"); if (Console.IsInputRedirected == false) { Console.WriteLine(" Press Esc to end."); } else { Console.WriteLine(); } while (true) { if (Console.IsInputRedirected == false && Console.KeyAvailable) { var key = Console.ReadKey(true); if (key.Key == ConsoleKey.Escape) { break; } } CoroutineMgr.Update(); System.Threading.Thread.Sleep(10); } return; } }