Exemplo n.º 1
0
        /// <summary>
        /// Processes either a return or inbound command
        /// </summary>
        public static void ProcessCommand(ref Command cmd)
        {
            if (cmd.src == Source.PLUGIN)
            {
                if (ProcessReturn != null)
                {
                    ProcessReturn(null, new CommandProcessEventArgs(cmd));
                }
            }
            else
            {
                CommandProcessEventArgs args = new CommandProcessEventArgs(cmd);

                if (ProcessInbound != null)
                {
                    ProcessInbound(null, args);
                }

                // post return, ensuring that retcode is valid
                if (args.Cmd.retCode == 0)
                {
                    args.Cmd.retCode = 1;
                }

                PostCommand(ref args.Cmd);
            }
        }
Exemplo n.º 2
0
        static void processInbound(object sender, CommandProcessEventArgs args)
        {
            Command cmd = args.Cmd;

            if (cmd.fourcc == "INVK")
            {
                string objectName = cmd.GetSParam(0);
                string methodName = cmd.GetSParam(1);

                List <string> parms = new List <string> ();

                int c = 1;
                for (int i = 0; i < cmd.iParams[0]; i++)
                {
                    parms.Add(Plugin.GetString(cmd.iParams [c], cmd.iParams [c + 1]));
                    c += 2;
                }

                string[] sparms = parms.ToArray();

                BridgeObject bo;
                if (objects.TryGetValue(objectName, out bo))
                {
                    bo.Invoke(methodName, sparms);
                }
            }
        }
Exemplo n.º 3
0
        public void OnProcessReturn(object sender, CommandProcessEventArgs args)
        {
            if (args.Cmd.id != cmd.id)
            {
                return;
            }

            Plugin.ProcessReturn -= OnProcessReturn;

            if (Process != null)
            {
                Process(null, args);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// default (empty) return value method
 /// </summary>
 static void processReturn(object sender, CommandProcessEventArgs args)
 {
 }
Exemplo n.º 5
0
    /// <summary>
    /// Event handler for view creation
    /// </summary>
    void processCRVW(object sender, CommandProcessEventArgs args)
    {
        Command cmd = args.Cmd;

        if (cmd.retCode > 0) {
            validate ();
            if (ViewCreated != null)
                ViewCreated (this);
        } else
            Debug.Log ("Error Creating View: " + Name);

        if (URL.Length != 0)
            LoadURL (URL);
    }
Exemplo n.º 6
0
 /// <summary>
 /// Default handler which consumes return value, if you specify your own return value handler you much consume 
 /// the return string with Plugin.GetString as below, otherwise you may run out of buffer allocations
 /// </summary>
 void defaultEvalResultHandler(object sender, CommandProcessEventArgs args)
 {
     // ensure we consume return value
     Plugin.GetString (args.Cmd.iParams [0], args.Cmd.iParams [1]);
 }
Exemplo n.º 7
0
    /// <summary>
    /// Event handler in response to a remove request
    /// </summary>
    void processRMVW(object sender, CommandProcessEventArgs args)
    {
        if (TSet != null)
            TSet.Release ();

        Object.DestroyObject (this);
        Object.DestroyObject (this.gameObject);
    }
Exemplo n.º 8
0
    /// <summary>
    /// Processes a resize of the UWKView, which can cause the backing textures to be 
    /// released/allocated.  This is an expensive operation and should be avoided if possible
    /// </summary>
    void processResize(object sender, CommandProcessEventArgs args)
    {
        Command cmd = args.Cmd;

        if (cmd.retCode > 0) {
            if (cmd.retCode == 2) {
                TSet.Release ();
                TSet = new TextureSet ();
                TSet.Init (Width, Height, SmartRects);
            } else {
            }
        } else
            Debug.Log ("Error Resizing View: " + Name);
    }
Exemplo n.º 9
0
    /// <summary>
    /// Inbound command event handler, responds to events generated by the native WebCore
    /// </summary>
    void processInbound(object sender, CommandProcessEventArgs args)
    {
        if (!Valid)
            return;

        Command cmd = args.Cmd;

        string name = cmd.GetSParam (0);

        if (name != Name)
            return;

        // Update the view
        if (cmd.fourcc == "UPVW") {
            UpdateView ();
        }

        // Update the associated view icon
        if (cmd.fourcc == "ICNC") {
            processIcon (ref cmd);
        }

        // Update the ContentSize of the web view
        if (cmd.fourcc == "UPCZ") {
            ContentWidth = cmd.iParams [0];
            ContentHeight = cmd.iParams [1];

            if (ResizeToContents && (Width != ContentWidth || Height != ContentHeight)) {
                Width = ContentWidth;
                Height = ContentHeight;

                sizeDirty = false;
            }
        }

        // Update the view's title
        if (cmd.fourcc == "TITC") {

            Title = cmd.GetSParam (1);

            if (TitleChanged != null)
                TitleChanged (this, Title);

        }

        // The progress of the page load to show progress bars, etc
        if (cmd.fourcc == "PROG") {

            if (LoadProgress != null)
                LoadProgress (cmd.iParams [0]);

        }

        // The WebView's content has finished loading
        if (cmd.fourcc == "LDFN") {

            if (LoadFinished != null)
                LoadFinished (this);
        }

        // The WebView's URL has changed either from user input or a redirect
        if (cmd.fourcc == "URLC") {
            string url = "";

            url = UWK.Plugin.GetString (cmd.iParams [0], cmd.iParams [1]);

            URL = url;
            if (URLChanged != null)
                URLChanged (this, url);

        }

        if (UWKCore.imeEnabled) {
            // ime out
            if (cmd.fourcc == "IMEO") {

                TextInputActive = false;

            }

            // ime in
            if (cmd.fourcc == "IMEI") {

                TextInputActive = true;

                TextInputType = cmd.GetSParam (1);

                if (cmd.iParams [1] != 0)
                    _imeText = Plugin.GetString (cmd.iParams [0], cmd.iParams [1]);
                else
                    _imeText = "";

                TextInputRect = new Rect (cmd.iParams [2], cmd.iParams [3], cmd.iParams [4], cmd.iParams [5]);

            }
        }
    }
Exemplo n.º 10
0
 /// <summary>
 /// default (empty) return value method
 /// </summary>
 static void processReturn(object sender, CommandProcessEventArgs args)
 {
 }
Exemplo n.º 11
0
        static void processInbound(object sender, CommandProcessEventArgs args)
        {
            Command cmd = args.Cmd;

            if (cmd.fourcc == "INVK") {
                string objectName = cmd.GetSParam (0);
                string methodName = cmd.GetSParam (1);

                List<string> parms = new List<string> ();

                int c = 1;
                for (int i = 0; i < cmd.iParams[0]; i++) {
                    parms.Add (Plugin.GetString (cmd.iParams [c], cmd.iParams [c + 1]));
                    c += 2;
                }

                string[] sparms = parms.ToArray ();

                BridgeObject bo;
                if (objects.TryGetValue (objectName, out bo)) {
                    bo.Invoke (methodName, sparms);
                }
            }
        }
Exemplo n.º 12
0
    void processInbound(object sender, CommandProcessEventArgs args)
    {
        Command cmd = args.Cmd;

        // activation
        if (cmd.fourcc == "ACTR") {

            processACTR (cmd);

        }
    }
Exemplo n.º 13
0
 void processReturn(object sender, CommandProcessEventArgs args)
 {
     //Command cmd = args.Cmd;
 }
Exemplo n.º 14
0
    void processInbound(object sender, CommandProcessEventArgs args)
    {
        Command cmd = args.Cmd;

        if (cmd.fourcc == "PRUP") {
            Plugin.UWK_InitProcess ();
        }

        // save cookies
        if (cmd.fourcc == "LDFN") {
            Command ncmd = Command.NewCommand ("SVCK");
            ncmd.Post ();
        }

        if (cmd.fourcc == "BOOT") {
            boot (ref cmd);
        }

        if (cmd.fourcc == "JLOG" && ShowJavascriptErrors) {

            string message = Plugin.GetString (cmd.iParams [0], cmd.iParams [1]);
            int lineNumber = cmd.iParams [2];
            string sourceId = Plugin.GetString (cmd.iParams [3], cmd.iParams [4]);

            Debug.Log ("Javascript: " + lineNumber + " : " + sourceId + " :  " + message);
        }

        // activation, we're still interested as the activation script may not be running
        if (cmd.fourcc == "ACTR") {

            processACTR (cmd);

        }

        if (cmd.fourcc == "POPU") {

            string name = Plugin.GetString (cmd.iParams [0], cmd.iParams [1]);

            int width = cmd.iParams [2];
            int height = cmd.iParams [3];

            CreateJSPopup (name, width, height);

        }

        if (cmd.fourcc == "POPC") {

            string name = Plugin.GetString (cmd.iParams [0], cmd.iParams [1]);

            if (!popups.ContainsKey (name)) {
                // this can happen if we close Unity side, we'll still get the call from the close slot
                // we could remove the slot native side to avoid this
                //Debug.LogWarning("Warning: CLoseJSPopupRequested called on missing popup");

            } else
                CloseJSPopupRequested (popups [name]);

        }
    }
Exemplo n.º 15
0
        /// <summary>
        /// Processes either a return or inbound command
        /// </summary>
        public static void ProcessCommand(ref Command cmd)
        {
            if (cmd.src == Source.PLUGIN) {

                if (ProcessReturn != null)
                    ProcessReturn (null, new CommandProcessEventArgs (cmd));

            } else {

                CommandProcessEventArgs args = new CommandProcessEventArgs (cmd);

                if (ProcessInbound != null) {
                    ProcessInbound (null, args);
                }

                // post return, ensuring that retcode is valid
                if (args.Cmd.retCode == 0)
                    args.Cmd.retCode = 1;

                PostCommand (ref args.Cmd);
            }
        }
Exemplo n.º 16
0
        public void OnProcessReturn(object sender, CommandProcessEventArgs args)
        {
            if (args.Cmd.id != cmd.id)
                return;

            Plugin.ProcessReturn -= OnProcessReturn;

            if (Process != null)
                Process (null, args);
        }