Example #1
0
        protected override bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception)
        {
            exception   = "";
            returnValue = CefV8Value.CreateUndefined();

            if (name == EndEncounterFunctionName)
            {
                EndEncounter?.Invoke(obj, new EndEncounterEventArgs());
            }
            else if (name == TakeScreenShotFunctionName)
            {
                if (arguments.Length > 0)
                {
                    TakeScreenShot?.Invoke(obj, new TakeScreenShotEventArgs(arguments[0].GetStringValue()));
                }
                else
                {
                    exception = "Invalid argument count.";
                }

                return(true);
            }
            else if (name == BroadcastMessageFunctionName)
            {
                if (arguments.Length > 0)
                {
                    BroadcastMessage?.Invoke(obj, new BroadcastMessageEventArgs(arguments[0].GetStringValue()));
                }
                else
                {
                    exception = "Invalid argument count.";
                }

                return(true);
            }
            else if (name == SendMessageFunctionName)
            {
                if (arguments.Length > 1)
                {
                    SendMessage?.Invoke(obj, new SendMessageEventArgs(arguments[0].GetStringValue(), arguments[1].GetStringValue()));
                }
                else
                {
                    exception = "Invalid argument count.";
                }

                return(true);
            }
            else if (name == OverlayMessageFunctionName)
            {
                if (arguments.Length > 1)
                {
                    OverlayMessage?.Invoke(obj, new SendMessageEventArgs(arguments[0].GetStringValue(), arguments[1].GetStringValue()));
                }
                else
                {
                    exception = "Invalid argument count.";
                }

                return(true);
            }

            return(false);
        }
Example #2
0
 internal static void OnOverlayMessage(object sender, SendMessageEventArgs e)
 {
     OverlayMessage?.Invoke(sender, e);
 }