felipeamaral / wami-recorder

Automatically exported from code.google.com/p/wami-recorder
0 stars 0 forks source link

How to capture server response data #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Let's say I record with URL. When it arrives on server side server will process 
and send back JSON at the end of the POST.

How can I capture this response from server and send to javascript?

I grabbed server response in SinglePost.as URLLoader class, but I don't know 
how to pass it to the page javascript.

Any thoughts?

Original issue reported on code.google.com by thebill...@gmail.com on 7 Feb 2012 at 11:08

GoogleCodeExporter commented 8 years ago
If it can be represented as a string in actionscript, you could try:
ExternalInterface.call("yourJavascriptFunction", responsStr);

Original comment by mcgrawian@gmail.com on 8 Feb 2012 at 4:24

GoogleCodeExporter commented 8 years ago
Any ideas on how to directly capture the JSON server response from Javascript? 
Similar to the XMLHttpRequest function using an event listener on "load". Bill, 
how did you end up doing this?

Original comment by shaunaa...@gmail.com on 22 Feb 2012 at 5:59

GoogleCodeExporter commented 8 years ago
My original idea was to try to add it in right with a callback and everything. 
But then I realized the External class in the package could just fire a quick 
call to javascript as long as I created the right js function.

So I added "External.serverReturn(loader.data);" as line 108 of SinglePost.as 
and then created javascript function "serverReturn(data)" on the page. Works 
like a charm.

Original comment by b...@smartots.com on 22 Feb 2012 at 6:37

GoogleCodeExporter commented 8 years ago
I am getting the following error when I add 
"External.serverReturn(loader.data);" to line 108 of SinglePost.as:

SinglePost.as(108): col: 13 Error: Call to a possibly undefined method 
serverReturn through a reference with static type Class.

Any ideas how to fix this?

Original comment by shaunaa...@gmail.com on 24 Feb 2012 at 5:48

GoogleCodeExporter commented 8 years ago
There is nothing in edu.mit.csail.wami.utils.External called serverReturn.  
Perhaps Bill added that himself... or perhaps he just called:  
External.call("serverReturn", loader.data);

Google ExternalInterface to learn more about the Adobe supplied functionality 
that communicates with Java.

Original comment by mcgrawian@gmail.com on 24 Feb 2012 at 8:20

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I noticed in the FAQ:
"Note that there are additional security restrictions in Flash's 
URLLoader.load() when using the multipart/form-data content type. We avoid 
these, but if necessary it is possible to send the audio back out to Javascript 
and use this content-type."

So I am guessing that we do not use multipart/form-data content type in WAMI? 
Do I use the ExternalInterface to send the audio back out to Javascript from 
SinglePost.as? I wish to take the audio and use HTML XMLHttpRequest method 
instead.

Original comment by shaunaa...@gmail.com on 28 Feb 2012 at 5:14

GoogleCodeExporter commented 8 years ago
That is indeed why we do not use multipart/form-data.  Yes, you can pass the 
audio through the JavaScript, but in most cases, it's just easier to configure 
your server to accept "audio/x-wav".  If you have to do it the other way, the 
answer is "yes it's possible"... but I haven't done it myself, so you're on 
you're own.

Original comment by mcgrawian@gmail.com on 28 Feb 2012 at 5:22

GoogleCodeExporter commented 8 years ago
Thanks for the response! The only thing is that I have no control over the 
server. The server is hosted by Zypr and it uses multipart/form-data to parse 
audio files. I will try to see if I can send audio back to Javascript.

Original comment by shaunaa...@gmail.com on 28 Feb 2012 at 3:29

GoogleCodeExporter commented 8 years ago
Oops - sorry for delay but my wife just had a baby a week ago so I've been a 
bit preoccupied.

I did indeed add "serverReturn" to External.as as shown by mcgrawian - 
"External.call("serverReturn", loader.data)"

Original comment by thebill...@gmail.com on 28 Feb 2012 at 10:09

GoogleCodeExporter commented 8 years ago

Original comment by mcgrawian@gmail.com on 1 Mar 2012 at 9:42

GoogleCodeExporter commented 8 years ago
I'm having a problem with this. I'm doing exactly as the instructions tell me, 
but when I do my recording it throws up a 500 Internal Server Error when trying 
to access my test.php file with the PHP script in. I've tried it on both of my 
servers but the same issue crops up and I don't know how to resolve it? Any 
ideas?

Thank you.

Original comment by burgerbu...@googlemail.com on 24 Jan 2013 at 9:01