Пример #1
0
 public static void OnMainLoop(ulong frame)
 {
     try
     {
         Entrypoints.OnMainLoop(frame);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
Пример #2
0
        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());
            }
        }
Пример #3
0
        public static int OnRunScript(string script, uint oidSelf)
        {
            var 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);
        }
Пример #4
0
        public static int Bootstrap(IntPtr arg, int argLength)
        {
            if (arg == (IntPtr)0)
            {
                Console.WriteLine("Received NULL bootstrap structure");
                return(1);
            }
            var expectedLength = 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);
        }