public static void OnMainLoop(ulong frame) { try { Entrypoints.OnMainLoop(frame); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static void OnSignal(string signal) { try { switch (signal) { case "ON_MODULE_LOAD_FINISH": Entrypoints.OnModuleLoad(); break; case "ON_DESTROY_SERVER": Entrypoints.OnShutdown(); break; } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static int OnRunScript(string script, uint oidSelf) { int ret = 0; OBJECT_SELF = oidSelf; ScriptContexts.Push(new ScriptContext { OwnerObject = oidSelf, ScriptName = script }); try { ret = Entrypoints.OnRunScript(script, oidSelf); } catch (Exception e) { Console.WriteLine(e.ToString()); } ScriptContexts.Pop(); OBJECT_SELF = ScriptContexts.Count == 0 ? OBJECT_INVALID : ScriptContexts.Peek().OwnerObject; return(ret); }
public static int Bootstrap(IntPtr arg, int argLength) { if (arg == (IntPtr)0) { Console.WriteLine("Received NULL bootstrap structure"); return(1); } int expectedLength = System.Runtime.InteropServices.Marshal.SizeOf(typeof(BootstrapArgs)); if (argLength < expectedLength) { Console.WriteLine($"Received bootstrap structure too small - actual={argLength}, expected={expectedLength}"); return(1); } if (argLength > expectedLength) { Console.WriteLine($"WARNING: Received bootstrap structure bigger than expected - actual={argLength}, expected={expectedLength}"); Console.WriteLine($" This usually means that native code version is ahead of the managed code"); } NativeFunctions = Marshal.PtrToStructure <BootstrapArgs>(arg); AllHandlers handlers; handlers.MainLoop = OnMainLoop; handlers.RunScript = OnRunScript; handlers.Closure = OnClosure; handlers.Signal = OnSignal; RegisterHandlers(handlers); try { Entrypoints.OnStart(); } catch (Exception e) { Console.WriteLine(e.ToString()); } return(0); }