Exemple #1
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);
         }
     }
 }
Exemple #2
0
        private void OnReconnectProc(string msg)
        {
            ADebug.Log("c#:OnReconnectProc: " + msg);
            ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
            ApolloResult       @int = (ApolloResult)apolloStringParser.GetInt("Result", 6);

            if (@int == ApolloResult.Success)
            {
                this.Connected = true;
            }
            else
            {
                this.Connected = false;
            }
            if (this.ReconnectEvent != null)
            {
                try
                {
                    this.ReconnectEvent(@int);
                }
                catch (Exception exception)
                {
                    ADebug.LogException(exception);
                }
            }
            else
            {
                ADebug.Log("OnReconnectProc ReconnectEvent is null");
            }
        }
Exemple #3
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");
            }
        }
Exemple #4
0
 private void OnUdpDataRecvedProc(string msg)
 {
     if (this.RecvedUdpDataEvent != null)
     {
         try
         {
             this.RecvedUdpDataEvent();
         }
         catch (Exception exception)
         {
             ADebug.LogException(exception);
         }
     }
 }
Exemple #5
0
 private void OnDataRecvedProc(string msg)
 {
     this.Connected = true;
     if (this.RecvedDataEvent != null)
     {
         try
         {
             this.RecvedDataEvent();
         }
         catch (Exception exception)
         {
             ADebug.LogException(exception);
         }
     }
 }
Exemple #6
0
        private void OnRouteChangedProc(string msg)
        {
            ulong serverId = new ApolloStringParser(msg).GetUInt64("serverId");

            if (this.RouteChangedEvent != null)
            {
                try
                {
                    this.RouteChangedEvent(serverId);
                }
                catch (Exception exception)
                {
                    ADebug.LogException(exception);
                }
            }
        }
Exemple #7
0
 public bool Encode(out byte[] buffer)
 {
     try
     {
         ApolloBufferWriter writer = new ApolloBufferWriter();
         this.BeforeEncode(writer);
         this.WriteTo(writer);
         buffer = writer.GetBufferData();
         return(true);
     }
     catch (Exception exception)
     {
         buffer = null;
         ADebug.LogException(exception);
         return(false);
     }
 }
Exemple #8
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);
         }
     }
 }
Exemple #9
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 #10
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);
                }
            }
        }
        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 #12
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 #13
0
 public bool Decode(byte[] data)
 {
     if (data != null)
     {
         try
         {
             ApolloBufferReader reader = new ApolloBufferReader(data);
             this.BeforeDecode(reader);
             this.ReadFrom(reader);
             bool flag   = true;
             bool result = flag;
             return(result);
         }
         catch (Exception exception)
         {
             ADebug.LogException(exception);
             bool flag2  = false;
             bool result = flag2;
             return(result);
         }
         return(false);
     }
     return(false);
 }