[Opa] Returning control to the browser
Alok Menghrajani
alok at fb.com
Tue Nov 29 01:23:10 EST 2011
You rock! Here is a pixpaste of a pixpaste being uploaded:
http://pixpaste.quaxio.com:8080/igwr
I noticed that if the async function is not recursive, chrome still
stalls. I.e. I have the feeling the @async applies to what happens inside
the function, not the function itself. Am I right, or is something else
going on?
Thanks again, this totally worked!!
Alok
On 11/28/11 6:54 PM, "Nicolas Glondu" <nicolas.glondu at mlstate.com> wrote:
>Le 28/11/2011 23:39, Alok Menghrajani a écrit :
>> Hi,
>>
>> I played around with @publish, and while it does let me use the @client
>>on
>> the outer loop, Chrome still ends up hanging :(
>Hi,
>
>You can solve most Chrome hanging issues by using asynchornous calls. It
>is also generally a good idea to annotate functions.
>
>Here is your example modified to work on Chrome :
>
>db /simple : string
>
>@async @client rec aux(data, length, piece_length, i) =
> if i < 100 then
> o:int = Int.of_float(Int.to_float(i) * piece_length)
> e:int = Int.of_float(Int.to_float(i+1) * piece_length)
> l:int =
> if e > length then length-o
> else e - o
> if l>0 then
> piece:string = String.substr(o, l, data)
> do Dom.set_text(#progress, "{i}%")
> do upload_piece(i, piece)
> aux(data, length, piece_length, i+1)
> else aux(data, length, piece_length, i+1)
> else void
>
>@client upload_data() = (
> data:string = Dom.get_value(#data)
> length:int = String.length(data)
> piece_length:float = Int.to_float(length) / 100.0
> aux(data, length, piece_length, 0)
>)
>
>@server @publish upload_piece(i:int, piece:string) = (
> do jlog("{i}")
> do /simple <- String.concat("", [/simple, piece])
> void
>)
>
>start() = (
> do /simple <- ""
><>
><textarea id=#data>{String.repeat(10000, "X")}</textarea>
><div id=#progress/>
><input type="button" onclick={_ -> upload_data()}/>
></>
>)
>
>server = Server.one_page_bundle("Simple", [], [], start)
>
>
>Note that annotating with "@server @publish_async" the function
>"upload_piece" whould have also worked on local examples. I did not use
>it because I think you can end with pieces in the wrong order when
>passing through Internet (delayed packets and things like that). In that
>case the number of the request can be used to check that pieces are in
>the right order.
>
>--
>Nicolas Glondu
>_______________________________________________
>Opa mailing list
>Opa at lists.owasp.org
>https://lists.owasp.org/mailman/listinfo/opa
More information about the Opa
mailing list