示例#1
0
 private void BeginResponseFlashCall(IAsyncResult ar)
 {
     try
     {
         RequestData asyncState = ar.AsyncState as RequestData;
         if (asyncState != null)
         {
             HttpWebResponse response = (HttpWebResponse)asyncState.Request.EndGetResponse(ar);
             if (response != null)
             {
                 Stream responseStream = response.GetResponseStream();
                 if (responseStream != null)
                 {
                     AMFMessage message = new AMFDeserializer(responseStream).ReadAMFMessage();
                     AMFBody    bodyAt  = message.GetBodyAt(0);
                     for (int i = 0; i < message.HeaderCount; i++)
                     {
                         AMFHeader headerAt = message.GetHeaderAt(i);
                         if (headerAt.Name == "RequestPersistentHeader")
                         {
                             this._netConnection.AddHeader(headerAt.Name, headerAt.MustUnderstand, headerAt.Content);
                         }
                     }
                     PendingCall call = asyncState.Call;
                     call.Result = bodyAt.Content;
                     if (bodyAt.Target.EndsWith("/onStatus"))
                     {
                         call.Status = 0x13;
                     }
                     else
                     {
                         call.Status = 2;
                     }
                     asyncState.Callback.ResultReceived(call);
                 }
                 else
                 {
                     this._netConnection.RaiseNetStatus("Could not aquire ResponseStream");
                 }
             }
             else
             {
                 this._netConnection.RaiseNetStatus("Could not aquire HttpWebResponse");
             }
         }
     }
     catch (Exception exception)
     {
         this._netConnection.RaiseNetStatus(exception);
     }
 }
示例#2
0
 private void BeginResponseFlexCall(IAsyncResult ar)
 {
     try
     {
         RequestData asyncState = ar.AsyncState as RequestData;
         if (asyncState != null)
         {
             HttpWebResponse response = (HttpWebResponse)asyncState.Request.EndGetResponse(ar);
             if (response != null)
             {
                 Stream responseStream = response.GetResponseStream();
                 if (responseStream != null)
                 {
                     PendingCall call;
                     AMFMessage  message = new AMFDeserializer(responseStream).ReadAMFMessage();
                     AMFBody     bodyAt  = message.GetBodyAt(0);
                     for (int i = 0; i < message.HeaderCount; i++)
                     {
                         AMFHeader headerAt = message.GetHeaderAt(i);
                         if (headerAt.Name == "RequestPersistentHeader")
                         {
                             this._netConnection.AddHeader(headerAt.Name, headerAt.MustUnderstand, headerAt.Content);
                         }
                     }
                     object content = bodyAt.Content;
                     if (content is ErrorMessage)
                     {
                         call        = asyncState.Call;
                         call.Result = content;
                         call.Status = 0x13;
                         asyncState.Callback.ResultReceived(call);
                     }
                     if (content is AcknowledgeMessage)
                     {
                         AcknowledgeMessage message2 = content as AcknowledgeMessage;
                         if ((this._netConnection.ClientId == null) && message2.HeaderExists("DSId"))
                         {
                             this._netConnection.SetClientId(message2.GetHeader("DSId") as string);
                         }
                         call        = asyncState.Call;
                         call.Result = message2.body;
                         call.Status = 2;
                         asyncState.Callback.ResultReceived(call);
                     }
                 }
                 else
                 {
                     this._netConnection.RaiseNetStatus("Could not aquire ResponseStream");
                 }
             }
             else
             {
                 this._netConnection.RaiseNetStatus("Could not aquire HttpWebResponse");
             }
         }
     }
     catch (Exception exception)
     {
         this._netConnection.RaiseNetStatus(exception);
     }
 }