Exemple #1
0
        static void onSendResultBuffer(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, int result, IntPtr buffer, int len)
        {
            //ADebug.Log("onSendResultBuffer enter:"+function+" "+objectId  + " buffer len:" + len);
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();

                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(int), typeof(byte[]) }, null);
                if (method != null)
                {
                    byte[] data = new byte[len];
                    if (buffer != IntPtr.Zero && len > 0)
                    {
                        Marshal.Copy(buffer, data, 0, len);
                    }
                    method.Invoke(obj, new object[] { result, data });
                    //ADebug.Log("onSendResultBuffer success");
                }
                else
                {
                    ADebug.LogError("onSendResultBuffer not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendResultBuffer:" + objectId + " do not exist");
            }
        }
Exemple #2
0
        static void onSendStruct(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr param)
        {
            //ADebug.Log("onSendStruct enter:"+function+" "+objectId);
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();


                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(IntPtr) }, null);
                if (method != null)
                {
                    method.Invoke(obj, new object[] { param });
                    //ADebug.Log("onSendStruct success");
                }
                else
                {
                    ADebug.LogError("onSendStruct not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendStruct:" + objectId + " do not exist");
            }
        }
Exemple #3
0
        static void onSendMessage(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPStr)] string param)
        {
            if (!ApolloObjectManager.Instance.dictObjectCollection.ContainsKey(objectId))
            {
                ADebug.LogError("onSendMessage not exist: " + objectId + " function:" + function + " param:" + param);
                return;
            }
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();

                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(string) }, null);
                if (method != null)
                {
                    method.Invoke(obj, new object[] { param });
                    //ADebug.Log("onSendMessage success");
                }
                else
                {
                    ADebug.LogError("onSendMessage not exist method:" + function);
                }
            }
            else
            {
                ADebug.Log("onSendMessage:" + objectId + " do not exist");
            }
        }
Exemple #4
0
        public void AddObject(ApolloObject obj)
        {
            if (obj == null)
            {
                return;
            }

            if (!dictObjectCollection.ContainsKey(obj.ObjectId))
            {
                dictObjectCollection.Add(obj.ObjectId, obj);

                //ADebug.Log("ApolloObjectManager AddObject:" + obj.ObjectId + " name:" + obj.GetType().FullName);
                addPlatformObject(obj.ObjectId, obj.GetType().FullName);
                //ADebug.Log("ApolloObjectManager after addApolloObject");
            }
        }
Exemple #5
0
        static void onSendResultStruct(UInt64 objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr resultBuffer, int resultLen)
        {
            ADebug.Log("onSendResultStruct enter:" + function + " " + objectId);
            ApolloObject obj = ApolloObjectManager.Instance.dictObjectCollection [objectId];

            if (obj != null && function != null)
            {
                Type type = obj.GetType();


                MethodInfo method = type.GetMethod(function, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Static, null,
                                                   new Type[] { typeof(Result) }, null);
                if (method != null)
                {
                    Result result    = Result.Unknown;
                    byte[] resultBuf = new byte[resultLen];
                    if (resultBuffer != IntPtr.Zero && resultLen > 0)
                    {
                        Marshal.Copy(resultBuffer, resultBuf, 0, resultLen);

                        if (!result.Decode(resultBuf))
                        {
                            ADebug.LogError("onSendResultStruct decode Error");
                            return;
                        }
                    }
                    else
                    {
                        ADebug.LogError("onSendResultStruct param Error");
                    }

                    method.Invoke(obj, new object[] { result });
                    //ADebug.Log("onSendStruct success");
                }
                else
                {
                    ADebug.LogError("onSendResult not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendResult:" + objectId + " do not exist");
            }
        }