예제 #1
0
        private static void onSendBuffer(ulong objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr buffer, int len)
        {
            ApolloObject obj2 = Instance.dictObjectCollection[objectId];

            if ((obj2 != null) && (function != null))
            {
                System.Type   type  = obj2.GetType();
                System.Type[] types = new System.Type[] { typeof(byte[]) };
                MethodInfo    info  = type.GetMethod(function, BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, types, null);
                if (info != null)
                {
                    byte[] destination = new byte[len];
                    Marshal.Copy(buffer, destination, 0, len);
                    object[] parameters = new object[] { destination };
                    info.Invoke(obj2, parameters);
                }
                else
                {
                    ADebug.LogError("onSendBuffer not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendBuffer:" + objectId + " do not exist");
            }
        }
예제 #2
0
 private static void onSendMessage(ulong objectId, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPStr)] string param)
 {
     if (!Instance.dictObjectCollection.ContainsKey(objectId))
     {
         ADebug.LogError(string.Concat(new object[] { "onSendMessage not exist: ", objectId, " function:", function, " param:", param }));
     }
     else
     {
         ApolloObject obj2 = Instance.dictObjectCollection[objectId];
         if ((obj2 != null) && (function != null))
         {
             System.Type[] types = new System.Type[] { typeof(string) };
             MethodInfo    info  = obj2.GetType().GetMethod(function, BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, types, null);
             if (info != null)
             {
                 object[] parameters = new object[] { param };
                 info.Invoke(obj2, parameters);
             }
             else
             {
                 ADebug.LogError("onSendMessage not exist method:" + function);
             }
         }
         else
         {
             ADebug.Log("onSendMessage:" + objectId + " do not exist");
         }
     }
 }
예제 #3
0
        private static void onSendResultBuffer(ulong objectId, [MarshalAs(20)] string function, int result, IntPtr buffer, int len)
        {
            ApolloObject apolloObject = ApolloObjectManager.Instance.dictObjectCollection[objectId];

            if (apolloObject != null && function != null)
            {
                Type       type   = apolloObject.GetType();
                MethodInfo method = type.GetMethod(function, 16777276, null, new Type[]
                {
                    typeof(int),
                    typeof(byte[])
                }, null);
                if (method != null)
                {
                    byte[] array = new byte[len];
                    if (buffer != IntPtr.Zero && len > 0)
                    {
                        Marshal.Copy(buffer, array, 0, len);
                    }
                    method.Invoke(apolloObject, new object[]
                    {
                        result,
                        array
                    });
                }
                else
                {
                    ADebug.LogError("onSendResultBuffer not exist method:" + function + " " + type.get_FullName());
                }
            }
            else
            {
                ADebug.LogError("onSendResultBuffer:" + objectId + " do not exist");
            }
        }
예제 #4
0
        private static void onSendStruct(ulong objectId, [MarshalAs(20)] string function, IntPtr param)
        {
            ApolloObject apolloObject = ApolloObjectManager.Instance.dictObjectCollection[objectId];

            if (apolloObject != null && function != null)
            {
                Type       type   = apolloObject.GetType();
                MethodInfo method = type.GetMethod(function, 16777276, null, new Type[]
                {
                    typeof(IntPtr)
                }, null);
                if (method != null)
                {
                    method.Invoke(apolloObject, new object[]
                    {
                        param
                    });
                }
                else
                {
                    ADebug.LogError("onSendStruct not exist method:" + function + " " + type.get_FullName());
                }
            }
            else
            {
                ADebug.LogError("onSendStruct:" + objectId + " do not exist");
            }
        }
예제 #5
0
 public void AddObject(ApolloObject obj)
 {
     if ((obj != null) && !this.dictObjectCollection.ContainsKey(obj.ObjectId))
     {
         this.dictObjectCollection.Add(obj.ObjectId, obj);
         addApolloObject(obj.ObjectId, obj.GetType().FullName);
     }
 }
예제 #6
0
 public void AddObject(ApolloObject obj)
 {
     if (obj == null)
     {
         return;
     }
     if (!this.dictObjectCollection.ContainsKey(obj.ObjectId))
     {
         this.dictObjectCollection.Add(obj.ObjectId, obj);
         ApolloObjectManager.addApolloObject(obj.ObjectId, obj.GetType().get_FullName());
     }
 }
예제 #7
0
        private static void onSendMessage(ulong objectId, [MarshalAs(20)] string function, [MarshalAs(20)] string param)
        {
            if (!ApolloObjectManager.Instance.dictObjectCollection.ContainsKey(objectId))
            {
                ADebug.LogError(string.Concat(new object[]
                {
                    "onSendMessage not exist: ",
                    objectId,
                    " function:",
                    function,
                    " param:",
                    param
                }));
                return;
            }
            ApolloObject apolloObject = ApolloObjectManager.Instance.dictObjectCollection[objectId];

            if (apolloObject != null && function != null)
            {
                Type       type   = apolloObject.GetType();
                MethodInfo method = type.GetMethod(function, 16777276, null, new Type[]
                {
                    typeof(string)
                }, null);
                if (method != null)
                {
                    method.Invoke(apolloObject, new object[]
                    {
                        param
                    });
                }
                else
                {
                    ADebug.LogError("onSendMessage not exist method:" + function);
                }
            }
            else
            {
                ADebug.Log("onSendMessage:" + objectId + " do not exist");
            }
        }
예제 #8
0
        private static void onSendStruct(ulong objectId, [MarshalAs(UnmanagedType.LPStr)] string function, IntPtr param)
        {
            ApolloObject obj2 = Instance.dictObjectCollection[objectId];

            if ((obj2 != null) && (function != null))
            {
                System.Type   type  = obj2.GetType();
                System.Type[] types = new System.Type[] { typeof(IntPtr) };
                MethodInfo    info  = type.GetMethod(function, BindingFlags.IgnoreReturn | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, types, null);
                if (info != null)
                {
                    object[] parameters = new object[] { param };
                    info.Invoke(obj2, parameters);
                }
                else
                {
                    ADebug.LogError("onSendStruct not exist method:" + function + " " + type.FullName);
                }
            }
            else
            {
                ADebug.LogError("onSendStruct:" + objectId + " do not exist");
            }
        }