예제 #1
0
        public T GetMsg <T>() where T : XMessage, new()
        {
            var obj = XObjectPool.Alloc <T>();

            obj.SetName(typeof(T).Name);
            return(obj);
        }
예제 #2
0
 //清除所有消息
 public void Clear()
 {
     foreach (var msgData in _msgDatas)
     {
         msgData.msg.Reset();
         XObjectPool.Free(msgData.msg);
     }
     _msgDatas.Clear();
 }
 public void Dispose()
 {
     foreach (var request in m_requests)
     {
         request.Reset();
         XObjectPool.Free(request);
     }
     m_requests.Clear();
 }
예제 #4
0
 public void Tick(float elapsedTime)
 {
     while (_msgDatas.Count > 0)
     {
         var msgData = _msgDatas.Dequeue();
         if (_HandleMsg(msgData.msg) || !_TransitMsg(msgData))
         {
             XObjectPool.Free(msgData.msg);
         }
     }
 }
        protected void _AddRequest(UnityWebRequest webRequest, string encrypt, Action <string, string> strResponse, Action <string, byte[]> binResponse, Action <float> onProgress)
        {
            var request = XObjectPool.Alloc <XWebRequest>();

            request.async       = webRequest.SendWebRequest();
            request.encrypt     = encrypt;
            request.strResponse = strResponse;
            request.binResponse = binResponse;
            request.onProgress  = onProgress;
            m_requests.Add(request);
        }
 public void Tick(float deltaTime)
 {
     if (m_requests.Count < 1)
     {
         return;
     }
     for (int i = 0; i < m_requests.Count;)
     {
         var request = m_requests[i];
         if (request.HandleRequest())
         {
             request.Reset();
             XObjectPool.Free(request);
             m_requests.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
 }