.Net/Flex: How to read partial results from URLReq

2019-07-30 07:10发布

问题:

I'm working on a batch process script that's executed from Flex. The batch script is in a .aspx Page and returns partial results through the following class:

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();
    }

}

In my Flex application I'd like to show the result as soon as it's flushed on server side. Can this be done using Actionscript?

回答1:

Short answer, no, you cannot do partial results over HTTP unless you do short/long polling (several http calls per minute). HTTP in it's essence is a request-response protocol.

What you want is a push technology, but I'm not sure if there's a .NET equivalent for this. On the Java side you got BlazeDS or GraniteDS for push messaging.

The other question is why are you results 'partial'?