Beispiel #1
0
        public static void AddScriptListener(int rMessageType, int rFilter, string scriptClassName, string scriptMethodName, bool rImmediate, bool staticBinding = true)
        {
#if JSSCRIPT
#elif LUASCRIPT
            LuaManager.Require(scriptClassName);
            LuaFunction func = LuaManager.GetFunction(scriptMethodName);
            if (func == null)
            {
                Debugger.LogError("register script listener func is null->" + scriptClassName + "^" + scriptMethodName);
                return;
            }
#endif

            MessageDispatcher.AddListener(rMessageType, rFilter, (message) =>
            {
#if JSSCRIPT
                JsRepresentClass jsRepresent = JsRepresentClassManager.Instance.AllocJsRepresentClass(JSClassName, staticBinding);

                if (message != null)
                {
                    jsRepresent.CallFunctionByFunName(JSMethodName, message.Data);
                }
#elif LUASCRIPT
                LuaManager.CallFunc_VX(func, message.Data);
#endif
            }, rImmediate);
        }
Beispiel #2
0
        private static IEnumerator _HttpGetSendBackString(string url, string ob, string className, string functionName)
        {
            WWW www = new WWW(url + "?" + ob);

            yield return(www);

            if (www.error != null)
            {
                Debugger.LogError("http get send error->" + www.error);
            }
            else
            {
                if (www.bytes != null)
                {
                    string data = System.Text.Encoding.UTF8.GetString(www.bytes);

                    if (!string.IsNullOrEmpty(data))
                    {
#if JSSCRIPT
                        JsRepresentClass jsRepresentClass =
                            JsRepresentClassManager.Instance.AllocJsRepresentClass(className, true);
                        jsRepresentClass.CallFunctionByFunName(functionName, data);
#elif LUASCRIPT
                        LuaManager.Require(className);
                        LuaInterface.LuaFunction func = LuaManager.GetFunction(functionName);
                        LuaManager.CallFunc_VX(func, data);
#endif
                    }
                }
                else
                {
                    Debugger.LogError("http get response data is null");
                }
            }

            www.Dispose();
        }