Esempio n. 1
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");
            }
        }
Esempio n. 2
0
 public void Action(ApolloActionBufferBase info, ApolloActionDelegate callback)
 {
     if (info == null)
     {
         ADebug.LogError("PayService Action Info == null");
     }
     else
     {
         byte[] buffer;
         if (!info.Encode(out buffer))
         {
             ADebug.LogError("Action Encode error!");
         }
         else
         {
             if (this.actionCallbackCollection.ContainsKey(info.Action))
             {
                 this.actionCallbackCollection[info.Action] = callback;
             }
             else
             {
                 this.actionCallbackCollection.Add(info.Action, callback);
             }
             apollo_pay_action(buffer, buffer.Length);
         }
     }
 }
Esempio n. 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");
            }
        }
Esempio n. 4
0
 public ApolloResult Send(TalkerMessageType type, TalkerCommand command, byte[] bodyData, int usedSize, ApolloMessage message)
 {
     if (command == null || bodyData == null || usedSize <= 0)
     {
         return(ApolloResult.InvalidArgument);
     }
     byte[] array = null;
     if (message == null)
     {
         message = new ApolloMessage();
     }
     if (message.PackRequestData(command, bodyData, usedSize, out array, type))
     {
         ADebug.Log(string.Concat(new object[]
         {
             "Sending:",
             command,
             " data size:",
             array.Length
         }));
         return(this.connector.WriteData(array, -1));
     }
     ADebug.LogError("Send: " + command + " msg.PackRequestData error");
     return(ApolloResult.InnerError);
 }
Esempio n. 5
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");
         }
     }
 }
Esempio n. 6
0
 private void parse(string src, Dictionary <string, string> collection)
 {
     if ((src == null) || (src.Length == 0))
     {
         ADebug.LogError("ApolloStringParser src is null");
     }
     else
     {
         char[] separator = new char[] { '&' };
         foreach (string str in src.Split(separator))
         {
             char[]   chArray2  = new char[] { '=' };
             string[] strArray3 = str.Split(chArray2);
             if (strArray3.Length > 1)
             {
                 if (collection.ContainsKey(strArray3[0]))
                 {
                     collection[strArray3[0]] = strArray3[1];
                 }
                 else
                 {
                     collection.Add(strArray3[0], strArray3[1]);
                 }
             }
         }
     }
 }
Esempio n. 7
0
 public ApolloResult Send(TalkerMessageType type, TalkerCommand command, IPackable request, ApolloMessage message)
 {
     if (command == null || request == null)
     {
         return(ApolloResult.InvalidArgument);
     }
     byte[] array = null;
     if (message == null)
     {
         message = new ApolloMessage();
     }
     if (message.PackRequestData(command, request, out array, type))
     {
         ADebug.Log(string.Concat(new object[]
         {
             "Sending:",
             command,
             " data size:",
             array.Length
         }));
         ApolloResult apolloResult = this.connector.WriteData(array, -1);
         if (apolloResult == ApolloResult.Success && message.Handler != null)
         {
             ApolloMessageManager.Instance.SeqMessageCollection.Add(message.SeqNum, message);
         }
         return(apolloResult);
     }
     ADebug.LogError("Send: " + command + " msg.PackRequestDat error");
     return(ApolloResult.InnerError);
 }
Esempio n. 8
0
 private void onRecvedData()
 {
     ADebug.Log("onRecvedData OnDataRecvedProc");
     while (true)
     {
         int    num;
         byte[] buffer = null;
         if (this.connector.ReadData(out buffer, out num) != ApolloResult.Success)
         {
             return;
         }
         try
         {
             ApolloMessage message = ApolloMessageManager.Instance.UnpackResponseData(buffer, num);
             if (message != null)
             {
                 ADebug.Log(string.Concat(new object[] { "Recved:", message.Command, " and resp is:", message.Response }));
                 ADebug.Log(string.Concat(new object[] { "OnDataRecvedProc: apolloMessage.Handler != null?: ", message.Handler != null, " apolloMessage.HandlerWithReceipt != null?: ", message.HandlerWithReceipt != null, " apolloMessage.HandlerWithoutReceipt != null?: ", message.HandlerWithoutReceipt != null }));
                 message.HandleMessage();
             }
             else
             {
                 ADebug.LogError("OnDataRecvedProc UnpackResponseData error");
             }
         }
         catch (Exception exception)
         {
             ADebug.LogException(exception);
         }
     }
 }
Esempio n. 9
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");
            }
        }
Esempio n. 10
0
 private void parse(string src, Dictionary <string, string> collection)
 {
     if (src == null || src.get_Length() == 0)
     {
         ADebug.LogError("ApolloStringParser src is null");
         return;
     }
     string[] array = src.Split(new char[]
     {
         '&'
     });
     string[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         string   text   = array2[i];
         string[] array3 = text.Split(new char[]
         {
             '='
         });
         if (array3.Length > 1)
         {
             if (collection.ContainsKey(array3[0]))
             {
                 collection.set_Item(array3[0], array3[1]);
             }
             else
             {
                 collection.Add(array3[0], array3[1]);
             }
         }
     }
 }
Esempio n. 11
0
        public ApolloResult ReadUdpData(out byte[] buffer, out int realLength)
        {
            buffer     = null;
            realLength = 0;
            if (!this.Connected)
            {
            }
            if (this.tempReadBuffer == null)
            {
                this.tempReadBuffer = new byte[ApolloCommon.ApolloInfo.MaxMessageBufferSize];
            }
            int          num          = this.tempReadBuffer.Length;
            ApolloResult apolloResult = ApolloConnector.apollo_connector_readUdpData(base.ObjectId, this.tempReadBuffer, ref num);

            if (apolloResult == ApolloResult.Success)
            {
                if (num == 0)
                {
                    ADebug.LogError("ReadUdpData empty len==0");
                    return(ApolloResult.Empty);
                }
                buffer     = this.tempReadBuffer;
                realLength = num;
            }
            return(apolloResult);
        }
Esempio n. 12
0
        private void OnConnectProc(string msg)
        {
            ADebug.Log("c#:OnConnectProc: " + msg);
            if (string.IsNullOrEmpty(msg))
            {
                ADebug.LogError("OnConnectProc msg is null");
                return;
            }
            ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
            ApolloResult       @int = (ApolloResult)apolloStringParser.GetInt("Result", 6);

            this.LoginInfo = apolloStringParser.GetObject <ApolloLoginInfo>("LoginInfo");
            if (@int == ApolloResult.Success)
            {
                this.Connected = true;
            }
            else
            {
                this.Connected = false;
            }
            ADebug.Log(string.Concat(new object[]
            {
                "c#:OnConnectProc: ",
                @int,
                " loginfo:",
                this.LoginInfo
            }));
            if (this.LoginInfo != null && this.LoginInfo.AccountInfo != null && this.LoginInfo.AccountInfo.TokenList != null)
            {
                ADebug.Log(string.Concat(new object[]
                {
                    "C# logininfo| platform:",
                    this.LoginInfo.AccountInfo.Platform,
                    " openid:",
                    this.LoginInfo.AccountInfo.OpenId,
                    " tokensize:",
                    this.LoginInfo.AccountInfo.TokenList.Count,
                    " pf:",
                    this.LoginInfo.AccountInfo.Pf,
                    " pfkey:",
                    this.LoginInfo.AccountInfo.PfKey
                }));
            }
            if (this.ConnectEvent != null)
            {
                try
                {
                    this.ConnectEvent(@int, this.LoginInfo);
                }
                catch (Exception exception)
                {
                    ADebug.LogException(exception);
                }
            }
            else
            {
                ADebug.Log("OnConnectProc ConnectEvent is null");
            }
        }
Esempio n. 13
0
        public void OnApolloPayActionProc(int ret, byte[] data)
        {
            ADebug.Log("OnApolloPayActionProc!");
            PluginBase currentPlugin = PluginManager.Instance.GetCurrentPlugin();

            if (currentPlugin == null)
            {
                ADebug.LogError("OnApolloPayActionProc plugin is null");
            }
            else
            {
                ApolloAction action = new ApolloAction();
                if (!action.Decode(data))
                {
                    ADebug.LogError("OnApolloPayActionProc Action Decode failed");
                }
                else if (this.actionCallbackCollection.ContainsKey(action.Action))
                {
                    ApolloActionBufferBase base3 = currentPlugin.CreatePayResponseAction(action.Action);
                    if (base3 != null)
                    {
                        if (!base3.Decode(data))
                        {
                            ADebug.LogError("OnApolloPayActionProc Decode failed");
                        }
                        else
                        {
                            ApolloActionDelegate delegate2 = this.actionCallbackCollection[action.Action];
                            if (delegate2 != null)
                            {
                                try
                                {
                                    delegate2((ApolloResult)ret, base3);
                                }
                                catch (Exception exception)
                                {
                                    ADebug.LogError("OnApolloPayActionProc exception:" + exception);
                                }
                            }
                            else
                            {
                                ADebug.LogError("OnApolloPayActionProc callback is null while action == " + action.Action);
                            }
                        }
                    }
                    else
                    {
                        ADebug.LogError("OnApolloPayActionProc info is null");
                    }
                }
                else
                {
                    ADebug.LogError("OnApolloPayActionProc not exist action:" + action.Action);
                }
            }
        }
 private void OnCrashExtMessageNotify(string msg)
 {
     try
     {
         if (this.onCrashExtMessageEvent != null)
         {
             this.onCrashExtMessageEvent();
         }
     }
     catch (Exception ex)
     {
         ADebug.LogError("OnCrashExtMessageNotify" + ex);
     }
 }
Esempio n. 15
0
 private void OnAccountInitializeProc(int ret, byte[] buf)
 {
     ADebug.Log("OnAccountInitializeProc result:" + (ApolloResult)ret);
     if (this.InitializeEvent != null)
     {
         try
         {
             this.InitializeEvent((ApolloResult)ret, null);
         }
         catch (Exception ex)
         {
             ADebug.LogError("OnAccountInitializeProc:" + ex);
         }
     }
 }
Esempio n. 16
0
 public ApolloResult SetRouteInfo(ApolloRouteInfoBase routeInfo)
 {
     byte[] buffer;
     if (routeInfo == null)
     {
         return(ApolloResult.InvalidArgument);
     }
     routeInfo.Encode(out buffer);
     if (buffer == null)
     {
         ADebug.LogError("WriteData Encode error!");
         return(ApolloResult.InnerError);
     }
     return(apollo_connector_setRouteInfo(base.ObjectId, buffer, buffer.Length));
 }
Esempio n. 17
0
 public ApolloResult SetRouteInfo(ApolloRouteInfoBase routeInfo)
 {
     if (routeInfo == null)
     {
         return(ApolloResult.InvalidArgument);
     }
     byte[] array;
     routeInfo.Encode(out array);
     if (array == null)
     {
         ADebug.LogError("WriteData Encode error!");
         return(ApolloResult.InnerError);
     }
     return(ApolloConnector.apollo_connector_setRouteInfo(base.ObjectId, array, array.Length));
 }
Esempio n. 18
0
 private void OnAccountLogoutProc(int ret)
 {
     ADebug.Log("OnAccountLogoutProc result:" + (ApolloResult)ret);
     if (this.LogoutEvent != null)
     {
         try
         {
             this.LogoutEvent((ApolloResult)ret);
         }
         catch (Exception ex)
         {
             ADebug.LogError("OnAccountLogoutProc:" + ex);
         }
     }
 }
 public void SendToQQWithRichPhoto(string summary, ApolloImgPaths imgFilePaths)
 {
     if (imgFilePaths != null)
     {
         byte[] array;
         imgFilePaths.Encode(out array);
         if (array != null)
         {
             ApolloSnsService.Apollo_Sns_SendToQQWithRichPhoto(base.ObjectId, summary, array, array.Length);
         }
         else
         {
             ADebug.LogError("SendToQQWithRichPhoto Encode Error");
         }
     }
 }
Esempio n. 20
0
 public static ApolloResult Initialize(NoneAccountInitInfo initInfo)
 {
     if (initInfo == null)
     {
         ADebug.LogError("NoneAccountService initInfo == null");
         return(ApolloResult.InvalidArgument);
     }
     byte[] buffer = null;
     if (initInfo.Encode(out buffer) && (buffer != null))
     {
         apollo_none_account_initialize(buffer, buffer.Length);
         return(ApolloResult.Success);
     }
     ADebug.LogError("NoneAccountService Encode error!");
     return(ApolloResult.InnerError);
 }
Esempio n. 21
0
 public static ApolloResult Initialize(NoneAccountInitInfo initInfo)
 {
     if (initInfo == null)
     {
         ADebug.LogError("NoneAccountService initInfo == null");
         return(ApolloResult.InvalidArgument);
     }
     byte[] array = null;
     if (initInfo.Encode(out array) && array != null)
     {
         NoneAccountService.apollo_none_account_initialize(array, array.Length);
         return(ApolloResult.Success);
     }
     ADebug.LogError("NoneAccountService Encode error!");
     return(ApolloResult.InnerError);
 }
Esempio n. 22
0
 private void onRecvedData()
 {
     ADebug.Log("onRecvedData OnDataRecvedProc");
     while (true)
     {
         byte[]       data = null;
         int          realSize;
         ApolloResult apolloResult = this.connector.ReadData(out data, out realSize);
         if (apolloResult != ApolloResult.Success)
         {
             break;
         }
         try
         {
             ApolloMessage apolloMessage = ApolloMessageManager.Instance.UnpackResponseData(data, realSize);
             if (apolloMessage != null)
             {
                 ADebug.Log(string.Concat(new object[]
                 {
                     "Recved:",
                     apolloMessage.Command,
                     " and resp is:",
                     apolloMessage.Response
                 }));
                 ADebug.Log(string.Concat(new object[]
                 {
                     "OnDataRecvedProc: apolloMessage.Handler != null?: ",
                     apolloMessage.Handler != null,
                     " apolloMessage.HandlerWithReceipt != null?: ",
                     apolloMessage.HandlerWithReceipt != null,
                     " apolloMessage.HandlerWithoutReceipt != null?: ",
                     apolloMessage.HandlerWithoutReceipt != null
                 }));
                 apolloMessage.HandleMessage();
             }
             else
             {
                 ADebug.LogError("OnDataRecvedProc UnpackResponseData error");
             }
         }
         catch (Exception exception)
         {
             ADebug.LogException(exception);
         }
     }
 }
Esempio n. 23
0
        private void OnRealNameAuthProc(byte[] data)
        {
            ADebug.Log("OnRealNameAuthProc!");
            ApolloRealNameAuthResult apolloRealNameAuthResult = new ApolloRealNameAuthResult();

            if (this.RealNameAutEvent != null && data.Length > 0)
            {
                if (!apolloRealNameAuthResult.Decode(data))
                {
                    ADebug.LogError("OnRealNameAuthProc Decode failed");
                }
                this.RealNameAutEvent(apolloRealNameAuthResult);
            }
            else
            {
                ADebug.Log("RealNameAutEvent is null");
            }
        }
Esempio n. 24
0
 public bool Initialize(ApolloBufferBase initInfo)
 {
     if (initInfo != null)
     {
         byte[] array;
         initInfo.Encode(out array);
         if (array != null)
         {
             return(ApolloAccountService.apollo_account_initialize(array, array.Length));
         }
         ADebug.LogError("Account Initialize Encode Error");
     }
     else
     {
         ADebug.LogError("Account Initialize param is null");
     }
     return(false);
 }
Esempio n. 25
0
 public bool Initialize(ApolloBufferBase initInfo)
 {
     if (initInfo != null)
     {
         byte[] buffer;
         initInfo.Encode(out buffer);
         if (buffer != null)
         {
             return(apollo_account_initialize(buffer, buffer.Length));
         }
         ADebug.LogError("Account Initialize Encode Error");
     }
     else
     {
         ADebug.LogError("Account Initialize param is null");
     }
     return(false);
 }
Esempio n. 26
0
 public void OnApolloPaySvrNotify(byte[] data)
 {
     ADebug.Log("ApolloPay OnApolloPaySvrNotify!");
     if (this.PayEvent != null)
     {
         PluginBase currentPlugin = PluginManager.Instance.GetCurrentPlugin();
         if (currentPlugin == null)
         {
             ADebug.LogError("OnApolloPaySvrNotify plugin is null");
         }
         else
         {
             ApolloAction action = new ApolloAction();
             if (!action.Decode(data))
             {
                 ADebug.LogError("OnApolloPaySvrNotify Action Decode failed");
             }
             else
             {
                 ApolloBufferBase payResponseInfo = currentPlugin.CreatePayResponseInfo(action.Action);
                 if (payResponseInfo != null)
                 {
                     if (!payResponseInfo.Decode(data))
                     {
                         ADebug.LogError("OnApolloPaySvrNotify Decode failed");
                     }
                     else
                     {
                         this.PayEvent(payResponseInfo);
                     }
                 }
                 else
                 {
                     ADebug.LogError("OnApolloPaySvrNotify info is null");
                 }
             }
         }
     }
     else
     {
         ADebug.Log("PayEvent is null");
     }
 }
Esempio n. 27
0
        private void OnConnectorErrorProc(string msg)
        {
            ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
            ApolloResult       @int = (ApolloResult)apolloStringParser.GetInt("Result", 6);

            ADebug.LogError("OnConnectorErrorProc:" + @int);
            this.Connected = false;
            if (this.ErrorEvent != null)
            {
                try
                {
                    this.ErrorEvent(@int);
                }
                catch (Exception exception)
                {
                    ADebug.LogException(exception);
                }
            }
        }
Esempio n. 28
0
 public void RealNameAuth(ApolloRealNameAuthInfo info)
 {
     if (info != null)
     {
         byte[] array;
         info.Encode(out array);
         if (array != null)
         {
             ApolloAccountService.apollo_account_realname_auth(array, array.Length);
         }
         else
         {
             ADebug.LogError("RealNameAuth Encode Error");
         }
     }
     else
     {
         ADebug.LogError("RealNameAuth param is null");
     }
 }
Esempio n. 29
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");
            }
        }
Esempio n. 30
0
        public IList ReadList <T>(ref T l)
        {
            int num = 0;

            this.Read(ref num);
            IList list = l as IList;

            if (list == null)
            {
                ADebug.LogError("ReadList list == null");
                return(null);
            }
            list.Clear();
            for (int i = 0; i < num; i++)
            {
                object obj = BasicClassTypeUtil.CreateListItem(list.GetType());
                this.Read <object>(ref obj);
                list.Add(obj);
            }
            return(list);
        }