Exemplo n.º 1
0
        private void OnRsp(RequestMessageWrapper sendMessageWrapper, HTTPResponse response)
        {
            if (response.GetFirstHeaderValue("msgId") == null)
            {
                Debug.Log("BEST HTTP :error message no message id on response header");
                return;
            }
            else
            {
                int messageId = int.Parse(response.GetFirstHeaderValue("msgId"));
                if (messageId == 400)
                {
                    GOEngine.DebugUtil.Log($"BEST HTTP :server error == 400  ,server ip:{this.m_serverIp}");
                }

                byte[] buffer = response.Data;

                if (!string.IsNullOrEmpty(response.GetFirstHeaderValue("errorCode")))
                {
                    int    errorCode    = int.Parse(response.GetFirstHeaderValue("errorCode"));
                    string errorContent = Encoding.UTF8.GetString(buffer);

                    EngineCoreEvents.SystemEvents.NetWorkError.SafeInvoke(errorCode, errorContent);
                }
                else
                {
                    IMessage message = EngineCore.MessageParser.Parse(messageId, buffer);

                    this.m_messageQueue.Enqueue(new ResponseMessageWrapper(messageId, message));


                    HttpPairCahce.EnCache(sendMessageWrapper.MessageBody);
                }
            }
        }
Exemplo n.º 2
0
        public override void Update()
        {
            if (this.m_httpClient != null)
            {
                ResponseMessageWrapper messageWrapper;
#if BEST_HTTP
                while (this.m_httpClient.MessageQueue.Count > 0)
                {
                    messageWrapper = this.m_httpClient.MessageQueue.Dequeue();

#if UNITY_DEBUG
                    if (1902 != messageWrapper.MessageId)
                    {
                        Debug.Log($"recv message : { messageWrapper.MessageBody.Descriptor.Name},detail{messageWrapper.MessageBody.ToString()}");
                    }
#endif
                    MessageHandler.Call(messageWrapper.MessageId, messageWrapper.MessageBody);
                    HttpPairCahce.DeCache();
                }
#else
                while (this.m_httpClient.MessageQueue.Dequeue(out messageWrapper))
                {
#if UNITY_DEBUG
                    Debug.Log($"recv message : { messageWrapper.MessageBody.Descriptor.Name},detail{messageWrapper.MessageBody.ToString()}");
#endif
                    MessageHandler.Call(messageWrapper.MessageId, messageWrapper.MessageBody);
                }
#endif

                this.OnRetryConnect.SafeInvoke();
            }
        }
Exemplo n.º 3
0
 public BestHttpClient(string serverIp)
 {
     this.m_serverIp      = serverIp;
     this.m_retry_wrapper = new HttpRetry();
     ResumeRetryMessage();
     m_is_retry_ui_show = false;
     HttpSendingCahce.Clear();
     HttpPairCahce.Clear();
     S_ATOMIC_COUNTER = 0;
     HTTPManager.MaxConnectionPerServer = 4;
 }
Exemplo n.º 4
0
 private IMessage PairOfReq()
 {
     return(HttpPairCahce.PeekCache());
 }