Exemple #1
0
 /// <summary>
 /// http respond
 /// </summary>
 /// <param name="package"></param>
 public void OnHttpRespond(HttpPackage package)
 {
     if (package.error != null)
     {
         OnNetError(package.ActionId, package.error);
     }
     else if (package.IsOverTime)
     {
         OnNetTimeOut(package.ActionId);
     }
     else
     {
         NetReader reader    = package.Reader;
         byte[]    buffBytes = package.GetResponse();
         if (reader.pushNetStream(buffBytes, NetworkType.Http, NetWriter.ResponseContentType))
         {
             if (reader.Success)
             {
                 OnRespond(package);
             }
             else
             {
                 OnNetError(package.ActionId, reader.Description);
             }
         }
     }
 }
Exemple #2
0
    public bool OnHttpRespond()
    {
        if (mCurrrentRequest.error != null)
        {
            mCurrrentRequest.Action.OnError(mCurrrentRequest.UserData);

            OnNetError(eNetError.eRequestFailed, mCurrrentRequest.ActionId, mCurrrentRequest.error);
            return(false);
        }
        else
        {
            byte[] buffBytes = mCurrrentRequest.GetResponse();

            uint    errorCode = 0;
            uint    sessionId = 0xFFFFFFFF;
            uint    actionId  = 0xFFFFFFFF;
            byte [] msgBody   = null;

            if (ParseError(buffBytes, ref errorCode))
            {// 发生系统错误
                if (errorCode == 2)
                {
                    OnNetError(eNetError.eInvalidActionId, mCurrrentRequest.ActionId);
                    return(false);
                }

                OnNetError(eNetError.eInvalidSession, mCurrrentRequest.ActionId);
                return(false);
            }

            if (!ParseData(buffBytes, ref sessionId, ref actionId, out msgBody))
            {
                mCurrrentRequest.Action.OnError(mCurrrentRequest.UserData);

                OnNetError(eNetError.eRequestFailed, mCurrrentRequest.ActionId, "ParseData");
                return(false);
            }

            mCurrrentRequest.Action.PutRespondMsg(msgBody, mCurrrentRequest.UserData);
            return(true);
        }
    }
Exemple #3
0
 /// <summary>
 /// http respond
 /// </summary>
 /// <param name="package"></param>
 /// <param name="userdata"></param>
 public void OnHttpRespond(HttpPackage package, object userdata)
 {
     if (package.error != null)
     {
         OnNetError(package.ActionId, package.error);
     }
     else if (package.IsOverTime)
     {
         OnNetTimeOut(package.ActionId);
     }
     else
     {
         NetReader reader    = package.Reader;
         byte[]    buffBytes = package.GetResponse();
         if (reader.pushNetStream(buffBytes, NetworkType.Http))
         {
             OnRespond(package);
         }
     }
 }
Exemple #4
0
 /// <summary>
 /// http respond
 /// </summary>
 /// <param name="package"></param>
 /// <param name="userdata"></param>
 public void OnHttpRespond(HttpPackage package, object userdata)
 {
     if (package.error != null)
     {
         OnNetError(package.ActionId, package.error);
     }
     else if (package.IsOverTime)
     {
         OnNetTimeOut(package.ActionId);
     }
     else
     {
         NetReader reader = package.Reader;
         byte[] buffBytes = package.GetResponse();
         if (reader.pushNetStream(buffBytes, NetworkType.Http))
         {
             OnRespond(package);
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// http respond
 /// </summary>
 /// <param name="package"></param>
 public void OnHttpRespond(HttpPackage package)
 {
     if (package.error != null)
     {
         OnNetError(package.ActionId, package.error);
     }
     else if (package.IsOverTime)
     {
         OnNetTimeOut(package.ActionId);
     }
     else
     {
         NetReader reader = package.Reader;
         byte[] buffBytes = package.GetResponse();
         if (reader.pushNetStream(buffBytes, NetworkType.Http, NetWriter.ResponseContentType))
         {
             if (reader.Success)
             {
                 OnRespond(package);
             }
             else
             {
                 OnNetError(package.ActionId, reader.Description);
             }
         }
     }
 }