Exemplo n.º 1
0
 protected Packet.State procImpl()
 {
     Packet.State state  = this.state_;
     Packet.State state2 = this.state_;
     if (state2 != Packet.State.Ready)
     {
         if (state2 != Packet.State.Process)
         {
             if (state2 == Packet.State.RetryWait)
             {
                 this.time_ += Time.deltaTime;
                 if (NetConfig.RetryWaitInSec <= this.time_)
                 {
                     this.reset();
                 }
             }
         }
         else
         {
             int state3 = this.client_.State;
             if (state3 != 4)
             {
                 if (state3 == 5)
                 {
                     this.procResult();
                 }
             }
             else
             {
                 MemoryStream response  = this.client_.getResponse();
                 byte[]       buffer    = response.GetBuffer();
                 string       response2 = (buffer == null) ? string.Empty : Encoding.UTF8.GetString(buffer, 0, (int)response.Length);
                 try
                 {
                     if (this.query_.setResponse(response2))
                     {
                         this.state_  = Packet.State.Done;
                         this.status_ = Packet.Status.OK;
                     }
                     else
                     {
                         this.state_  = Packet.State.Error;
                         this.status_ = Packet.Status.Error_DecodeResponse;
                     }
                 }
                 catch
                 {
                     this.state_  = Packet.State.Error;
                     this.status_ = Packet.Status.Error_DecodeResponse;
                 }
                 this.clear();
             }
         }
     }
     else
     {
         try
         {
             string request = this.query_.getRequest();
             if (!this.client_.request(Encoding.UTF8.GetBytes(request), NetPacketUtil.getUserAgent(this.query_), this.query_.Compress))
             {
                 this.procResult();
             }
             else
             {
                 this.state_ = Packet.State.Process;
             }
         }
         catch
         {
             this.state_  = Packet.State.Error;
             this.status_ = Packet.Status.Error_EcodeRequest;
         }
     }
     if (state != this.state_ && (this.state_ == Packet.State.Done || this.state_ == Packet.State.Error))
     {
         Singleton <OperationManager> .instance.onPacketFinish(this.status_);
     }
     return(this.state_);
 }