Exemple #1
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");
            }
        }
Exemple #2
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);
 }
Exemple #3
0
 private void OnFeedbackNotify(string msg)
 {
     ADebug.Log("onFeedbackEvent:" + msg);
     if (this.onFeedbackEvent != null)
     {
         ApolloStringParser parser = new ApolloStringParser(msg);
         int    @int = parser.GetInt("Flag");
         string desc = parser.GetString("Desc");
         try
         {
             this.onFeedbackEvent(@int, desc);
         }
         catch (Exception exception)
         {
             ADebug.Log("onFeedbackEvent:" + exception);
         }
     }
 }
Exemple #4
0
 public ApolloResult Register <TResp>(TalkerCommand command, TalkerMessageWithoutReceiptHandler <TResp> handler) where TResp : IUnpackable
 {
     if (command != null && handler != null)
     {
         ADebug.Log("Register:" + command);
         if (ApolloMessageManager.Instance.Exist(command))
         {
         }
         ApolloMessage apolloMessage = new ApolloMessage(command);
         apolloMessage.RespType = typeof(TResp);
         apolloMessage.HandlerWithoutReceipt = delegate(IUnpackable resp)
         {
             handler((TResp)((object)resp));
         };
         ApolloMessageManager.Instance.Add(apolloMessage);
         return(ApolloResult.Success);
     }
     return(ApolloResult.InvalidArgument);
 }
Exemple #5
0
 public bool Decode(byte[] data)
 {
     if (data != null)
     {
         try
         {
             ApolloBufferReader reader = new ApolloBufferReader(data);
             this.BeforeDecode(reader);
             this.ReadFrom(reader);
             return(true);
         }
         catch (Exception exception)
         {
             ADebug.LogException(exception);
             return(false);
         }
     }
     return(false);
 }
Exemple #6
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);
                }
            }
        }
Exemple #7
0
 private void OnLocationGotNotify(string msg)
 {
     if (msg.get_Length() > 0)
     {
         ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
         ApolloLocation     @object            = apolloStringParser.GetObject <ApolloLocation>("Location");
         if (this.onLocationGotEvent != null)
         {
             try
             {
                 this.onLocationGotEvent(@object);
             }
             catch (Exception ex)
             {
                 ADebug.Log("onLocationGotEvent:" + ex);
             }
         }
     }
 }
Exemple #8
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");
     }
 }
Exemple #9
0
        public ApolloResult GetRecord(ref ApolloAccountInfo pAccountInfo)
        {
            StringBuilder stringBuilder = new StringBuilder(4096);
            ApolloResult  apolloResult  = ApolloAccountService.apollo_account_getRecord(base.ObjectId, stringBuilder, 4096);
            string        text          = stringBuilder.ToString();

            ADebug.Log(string.Concat(new object[]
            {
                "GetRecord:",
                apolloResult,
                ", ",
                text
            }));
            if (text.get_Length() > 0)
            {
                pAccountInfo.FromString(text);
            }
            return(apolloResult);
        }
 private void OnShareNotify(string msg)
 {
     if (msg.get_Length() > 0)
     {
         ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
         ApolloShareResult  @object            = apolloStringParser.GetObject <ApolloShareResult>("ShareResult");
         if (this.onShareEvent != null)
         {
             try
             {
                 this.onShareEvent(@object);
             }
             catch (Exception ex)
             {
                 ADebug.Log("onShareEvent:" + ex);
             }
         }
     }
 }
Exemple #11
0
 private void OnConnectProc(string msg)
 {
     ADebug.Log("c#:OnConnectProc: " + msg);
     if (string.IsNullOrEmpty(msg))
     {
         ADebug.LogError("OnConnectProc msg is null");
     }
     else
     {
         ApolloStringParser parser = new ApolloStringParser(msg);
         ApolloResult       @int   = (ApolloResult)parser.GetInt("Result", 6);
         this.LoginInfo = parser.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");
         }
     }
 }
 private void OnLocationNotify(string msg)
 {
     if (msg.Length > 0)
     {
         ApolloStringParser parser    = new ApolloStringParser(msg);
         ApolloRelation     aRelation = null;
         aRelation = parser.GetObject <ApolloRelation>("Relation");
         if (this.onLocationEvent != null)
         {
             try
             {
                 this.onLocationEvent(aRelation);
             }
             catch (Exception exception)
             {
                 ADebug.Log("onLocationEvent:" + exception);
             }
         }
     }
 }
        public bool Encode(out byte[] buffer)
        {
            bool result;

            try
            {
                ApolloBufferWriter apolloBufferWriter = new ApolloBufferWriter();
                this.BeforeEncode(apolloBufferWriter);
                this.WriteTo(apolloBufferWriter);
                buffer = apolloBufferWriter.GetBufferData();
                result = true;
            }
            catch (Exception exception)
            {
                buffer = null;
                ADebug.LogException(exception);
                result = false;
            }
            return(result);
        }
Exemple #14
0
 private void OnQueryGroupKeyNotify(string msg)
 {
     ADebug.Log("OnQueryGroupKeyNotify");
     if (msg.get_Length() > 0)
     {
         ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
         ApolloGroupResult  @object            = apolloStringParser.GetObject <ApolloGroupResult>("GroupResult");
         if (this.onQueryGroupKeyEvent != null)
         {
             try
             {
                 this.onQueryGroupKeyEvent(@object);
             }
             catch (Exception ex)
             {
                 ADebug.Log("OnQueryGroupKeyNotify:" + ex);
             }
         }
     }
 }
Exemple #15
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");
     }
 }
Exemple #16
0
 private void OnShareNotify(string msg)
 {
     if (msg.Length > 0)
     {
         ApolloStringParser parser            = new ApolloStringParser(msg);
         ApolloShareResult  shareResponseInfo = null;
         shareResponseInfo = parser.GetObject <ApolloShareResult>("ShareResult");
         if (this.onShareEvent != null)
         {
             try
             {
                 this.onShareEvent(shareResponseInfo);
             }
             catch (Exception exception)
             {
                 ADebug.Log("onShareEvent:" + exception);
             }
         }
     }
 }
Exemple #17
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");
            }
        }
Exemple #18
0
 private void OnBindGroupNotify(string msg)
 {
     ADebug.Log("OnBindGroupNotify");
     if (msg.Length > 0)
     {
         ApolloStringParser parser   = new ApolloStringParser(msg);
         ApolloGroupResult  groupRet = null;
         groupRet = parser.GetObject <ApolloGroupResult>("GroupResult");
         if (this.onBindGroupEvent != null)
         {
             try
             {
                 this.onBindGroupEvent(groupRet);
             }
             catch (Exception exception)
             {
                 ADebug.Log("OnBindGroupNotify:" + exception);
             }
         }
     }
 }
 public void SendToWeixinWithMusic(ApolloShareScene aScene, string title, string desc, string musicUrl, string musicDataUrl, string mediaTagName, byte[] imageData, int imageDataLen, string messageExt, string messageAction)
 {
     ADebug.Log(string.Concat(new string[]
     {
         "CApolloSnsService::SendToWeixinWithMusic title:",
         title,
         "desc:",
         desc,
         "musicUrl:",
         musicUrl,
         "musicDataUrl:",
         musicDataUrl,
         "mediaTagName:",
         mediaTagName,
         "messageExt:",
         messageExt,
         "messageAction:",
         messageAction
     }));
     ApolloSnsService.Apollo_Sns_SendToWeixinWithMusic(base.ObjectId, aScene, title, desc, musicUrl, musicDataUrl, mediaTagName, imageData, imageDataLen, messageExt, messageAction);
 }
 public bool SendToWXGameFriend(string fOpenId, string title, string description, string mediaId, string messageExt, string mediaTagName, string msdkExtInfo)
 {
     ADebug.Log(string.Concat(new string[]
     {
         "CApolloSnsService::SendToWXGameFriend fOpenId:",
         fOpenId,
         "title:",
         title,
         "description:",
         description,
         "mediaId:",
         mediaId,
         "messageExt:",
         messageExt,
         "mediaTagName:",
         mediaTagName,
         "msdkExtInfo:",
         msdkExtInfo
     }));
     return(ApolloSnsService.Apollo_Sns_SendToWXGameFriend(base.ObjectId, fOpenId, title, description, mediaId, messageExt, mediaTagName, msdkExtInfo));
 }
        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);
        }
Exemple #22
0
        private void OnDisconnectProc(string msg)
        {
            ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
            ApolloResult       @int = (ApolloResult)apolloStringParser.GetInt("Result");

            if (@int == ApolloResult.Success)
            {
                this.Connected = false;
            }
            if (this.DisconnectEvent != null)
            {
                try
                {
                    this.DisconnectEvent(@int);
                }
                catch (Exception exception)
                {
                    ADebug.LogException(exception);
                }
            }
        }
Exemple #23
0
        private void onAccessTokenRefresedProc(string msg)
        {
            ADebug.Log("onAccessTokenRefresedProc: " + msg);
            ApolloStringParser     apolloStringParser = new ApolloStringParser(msg);
            ListView <ApolloToken> listView           = null;
            ApolloResult           @int = (ApolloResult)apolloStringParser.GetInt("Result");

            if (@int == ApolloResult.Success)
            {
                string text = apolloStringParser.GetString("tokens");
                if (text != null)
                {
                    text = ApolloStringParser.ReplaceApolloString(text);
                    ADebug.Log("onAccessTokenRefresedProc tokens:" + text);
                    if (text != null && text.get_Length() > 0)
                    {
                        string[] array = text.Split(new char[]
                        {
                            ','
                        });
                        listView = new ListView <ApolloToken>();
                        string[] array2 = array;
                        for (int i = 0; i < array2.Length; i++)
                        {
                            string src   = array2[i];
                            string text2 = ApolloStringParser.ReplaceApolloString(src);
                            text2 = ApolloStringParser.ReplaceApolloString(text2);
                            ApolloToken apolloToken = new ApolloToken();
                            apolloToken.FromString(text2);
                            ADebug.Log(string.Format("onAccessTokenRefresedProc str:{0} |||||| {1}   |||||{2}", text2, apolloToken.Type, apolloToken.Value));
                            listView.Add(apolloToken);
                        }
                    }
                }
            }
            if (this.RefreshAtkEvent != null)
            {
                this.RefreshAtkEvent(@int, listView);
            }
        }
 private void OnJoinWXGroupNotify(byte[] data)
 {
     if (data.Length > 0)
     {
         ApolloGroupResult apolloGroupResult = new ApolloGroupResult();
         if (!apolloGroupResult.Decode(data))
         {
             ADebug.Log("OnJoinWXGroupNotify Decode failed");
         }
         if (this.onJoinWXGroupEvent != null)
         {
             try
             {
                 this.onJoinWXGroupEvent(apolloGroupResult);
             }
             catch (Exception ex)
             {
                 ADebug.Log("OnJoinWXGroupNotify:" + ex);
             }
         }
     }
 }
 public void StartWithTalker(IApolloTalker talker, float intervalBetweenCollections = 2f)
 {
     this.intervalBetweenCollections = intervalBetweenCollections;
     this.ResetTimeInterval();
     this.talker = (talker as ApolloTalker);
     if (this.talker == null)
     {
         throw new Exception("Talker must not be null !");
     }
     this.talker.Register <ApolloTSS>(TalkerCommand.CommandDomain.TSS, delegate(ApolloTSS resp)
     {
         if (resp != null)
         {
             ADebug.Log("tss recv data len:" + resp.wLen);
             TssSdk.TssSdkRcvAntiData(resp.szData, resp.wLen);
         }
         else
         {
             ADebug.Log("Tss resp  is null");
         }
     });
 }
Exemple #26
0
        public HttpReq PackRequest()
        {
            RequestLine requestLine = new RequestLine();

            requestLine.szRequestMethod = this.method;
            requestLine.szRequestUri    = this.URL;
            requestLine.szHttpVersion   = this.version;
            ListLinqView <HeaderUnit> listLinqView = new ListLinqView <HeaderUnit>();

            using (Dictionary <string, string> .Enumerator enumerator = this.headers.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <string, string> current = enumerator.get_Current();
                    byte[] bytes  = Encoding.get_UTF8().GetBytes(current.get_Key());
                    byte[] bytes2 = Encoding.get_UTF8().GetBytes(current.get_Value());
                    listLinqView.Add(new HeaderUnit
                    {
                        szHeaderName    = bytes,
                        szHeaderContent = bytes2
                    });
                }
            }
            HttpHeaders httpHeaders = new HttpHeaders();

            httpHeaders.astHeaderUnit = listLinqView.ToArray();
            httpHeaders.dwHeaderCount = (uint)httpHeaders.astHeaderUnit.Length;
            RequestContent requestContent = new RequestContent();

            requestContent.szData    = this.data;
            requestContent.dwDataLen = (uint)this.data.Length;
            HttpReq httpReq = new HttpReq();

            httpReq.stRequestLine    = requestLine;
            httpReq.stHttpHeaders    = httpHeaders;
            httpReq.stRequestContent = requestContent;
            ADebug.Log("send request :" + this.ToString());
            return(httpReq);
        }
        public bool ApolloRepoertEvent(string eventName, List <KeyValuePair <string, string> > events, bool isReal)
        {
            if (eventName == null)
            {
                return(false);
            }
            string text = string.Empty;

            if (events != null)
            {
                for (int i = 0; i < events.get_Count(); i++)
                {
                    KeyValuePair <string, string> keyValuePair = events.get_Item(i);
                    if (keyValuePair.get_Key() == null)
                    {
                        ADebug.LogError(string.Format("ApolloReportService e.Key null:eventName{0}", eventName));
                    }
                    else
                    {
                        if (keyValuePair.get_Value() == null)
                        {
                            keyValuePair = new KeyValuePair <string, string>(keyValuePair.get_Key(), string.Empty);
                            ADebug.LogError(string.Format("ApolloReportService e.Value null:eventName{0}", eventName));
                        }
                        string text2 = text;
                        text = string.Concat(new string[]
                        {
                            text2,
                            keyValuePair.get_Key(),
                            ":",
                            keyValuePair.get_Value(),
                            ","
                        });
                    }
                }
            }
            ApolloReportService.ApolloReportEvent(base.ObjectId, eventName, text, isReal);
            return(true);
        }
Exemple #28
0
 private void DealRsp(HttpRsp rsp, ApolloResult rst)
 {
     if (rst == ApolloResult.Success)
     {
         ApolloHttpResponse apolloHttpResponse = new ApolloHttpResponse();
         string             httpVersion        = this.ByteArray2String(rsp.stResponseStatus.szHttpVersion);
         apolloHttpResponse.SetHttpVersion(httpVersion);
         string status = this.ByteArray2String(rsp.stResponseStatus.szStatusCode);
         apolloHttpResponse.SetStatus(status);
         string statusMessage = this.ByteArray2String(rsp.stResponseStatus.szReasonPhrase);
         apolloHttpResponse.SetStatusMessage(statusMessage);
         int num = 0;
         while ((long)num < (long)((ulong)rsp.stHttpHeaders.dwHeaderCount))
         {
             HeaderUnit headerUnit = rsp.stHttpHeaders.astHeaderUnit[num];
             string     name       = this.ByteArray2String(headerUnit.szHeaderName);
             string     value      = this.ByteArray2String(headerUnit.szHeaderContent);
             apolloHttpResponse.SetHeader(name, value);
             num++;
         }
         apolloHttpResponse.SetData(rsp.stResponseContent.szData, rsp.stResponseContent.dwDataLen);
         ADebug.Log("Get Result Response :" + apolloHttpResponse.ToString());
         this.responses.Add(apolloHttpResponse);
         if (this.ResponseEvent != null)
         {
             IApolloHttpResponse rsp2 = apolloHttpResponse;
             this.ResponseEvent(rsp2, rst);
         }
     }
     else if (rst == ApolloResult.Timeout)
     {
         this.gotTimeout = true;
     }
     else
     {
         ADebug.LogError("Got recv error :" + rst);
     }
 }
Exemple #29
0
 public void HandleMessage()
 {
     if (this.Handler != null)
     {
         TalkerEventArgs e = new TalkerEventArgs(this.Response, this.Context);
         this.Handler(this.Request, e);
     }
     else if (this.HandlerWithoutReceipt != null)
     {
         this.HandlerWithoutReceipt(this.Response);
     }
     else if (this.HandlerWithReceipt != null)
     {
         IPackable packable = null;
         this.HandlerWithReceipt(this.Response, ref packable);
         if (packable != null)
         {
             ADebug.Log("HandlerWithReceipt receipt:" + packable);
             if (this.Talker != null && packable != null)
             {
                 this.Talker.SendReceipt <NullResponse>(packable, this.AsyncFlag);
             }
             else
             {
                 ADebug.Log("HandlerWithReceipt without receipt");
             }
         }
     }
     else if (this.RawMessageHandler != null)
     {
         ADebug.Log(("RawMessageHandler raw data size:" + this.RawData != null) ? this.RawData.Length : 0);
         this.RawMessageHandler(new RawMessageEventArgs(this.RawData));
     }
     if (this.IsRequest)
     {
         ApolloMessageManager.Instance.RemoveMessage(this);
     }
 }
 public void Action(ApolloActionBufferBase info, ApolloActionDelegate callback)
 {
     if (info == null)
     {
         ADebug.LogError("PayService Action Info == null");
         return;
     }
     byte[] array;
     if (!info.Encode(out array))
     {
         ADebug.LogError("Action Encode error!");
         return;
     }
     if (this.actionCallbackCollection.ContainsKey(info.Action))
     {
         this.actionCallbackCollection[info.Action] = callback;
     }
     else
     {
         this.actionCallbackCollection.Add(info.Action, callback);
     }
     ApolloPayService.apollo_pay_action(array, array.Length);
 }