2011-03-17 70 views
1

我正在處理從Flex執行的批處理腳本。該批處理腳本是在.aspx頁面中,通過下面的類返回部分結果:.Net/Flex:如何閱讀URLRequest的部分結果?

public class ResponseLogger 
{ 

    private HttpResponse _response; 

    public ResponseLogger(HttpResponse response) 
    { 
     this._response = response; 
    } 

    public void Start() 
    { 
     _response.Clear(); 
     _response.ContentType = "text/plain"; 
     _response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); 
    } 

    public void End() 
    { 
     _response.End(); 
    } 

    public void Br() 
    { 
     Log(""); 
    } 

    public void Underline(string message) 
    { 
     Log(message); 
     Log("".PadLeft(message.Length, '-')); 

    } 

    public void Log(string message) 
    { 
     _response.Write(message + "\n"); 
     _response.Flush(); 
    } 

} 

在我的Flex應用程序,我想盡快,因爲它是刷新在服務器端顯示的結果。這可以使用Actionscript完成嗎?

+0

我沒有太多的.NET經驗(特別是我只使用WPF和稀疏的服務),它看起來像你基本上有興趣實現一個「推」服務,其中數據從服務器推送到客戶端,我不知道這是可能的使用.NET,但這裏有一個很好的寫作:http://codeofdoom.com/wordpress/2009/01/29/blazeds-data-push-with-remote-objects/ – shaunhusain 2011-03-17 19:14:22

+0

那麼簡單的URLLoader方式呢?或者可能有一些共謀WebServices的方法呢? – Eugene 2011-03-17 20:30:06

回答

1

簡而言之,不,你不能通過HTTP做部分結果,除非你做短/長輪詢(每分鐘幾個http調用)。 HTTP本質上是一個請求 - 響應協議。

你想要的是推技術,但我不確定是否有.NET的等價物。在Java方面,你有BlazeDS或GraniteDS推送消息。

另一個問題是爲什麼你的結果'偏'?