How to let Flash app communicate with server? - javascript

What's an easy and secure way to let my Flash app communicate with my back-end server?
The Flash app, which is a video player, should retrieve the person's username and send back an ID. How would I do this?
Note: Back-end is written in Javascript.

If you want to connect flash with JS to actionscript use ExternalInterface. If you want to connect to e.g. PHP use NetConnection or UrlLoader

I've used XML-RPC in a Flash client before. I've gotten it to work pretty well too.
I've personally used this Action Script 3 implementation:
http://danielmclaren.com/2007/08/03/xmlrpc-for-actionscript-30-free-library
Of course, the server I was talking with was Java/Tomcat. However, I'm pretty sure there are XML-RPC implementations for JavaScript; a quick search found this:
http://phpxmlrpc.sourceforge.net/jsxmlrpc/
Don't know how much setup/overhead it would be for you server-wise, but I've had success with that protocol.

Related

Is it bad to put your imgur client id in javascript?

I'm working on an application that uses imgur as hosting service and I'll be uploading images to imgur using javascript. But that means I have to put the client id in my code so everyone will be able to see my client id when they look at the source. Is this bad and if so what can I do as a workaround?
Thanks!
It's only bad if you don't want other people use your client id.
You can use node.js to use the same javascript you are using now, but on the server side.
That way you don't have to learn a new language, but get all the benefits from keeping it on the server.
Good luck,
bovako

WebSocket Server Javascript Implementation

I have recently discovered HTML 5's support for the WebSocket protocol. I began idly experimenting with it and I decided to undertake a simple chat program project. For it, I'd like to be able write a WebSocket server and have it serve users inside of a blog post, using Google's Blogger website.
The server would be written in Javascript and would have all the code needed to send one person's "conversation line" to all other WebSocket connections connected to it. Later, I may implement "chatrooms" where each line is simply redirected to certain users.
My first question: would it be possible to create a Javascript-based WebSocket server? I've researched a bit, and it seems that all server implementations were in PHP or some server-side language similar to that. Would it be possible to write a WebSocket server with Javascript?
The server implementation would be inside of a webpage, so as long as the blog is up, the server would work as well. My blog can be found here. The client's code would be like this:
server = "http://imdmstromyf8imdcaptomysl.blogspot.com/post_that_handles_chat";
connection = new WebSocket (server);
The problem is, a WebSocket runs on its own protocol (ws:// or wss://), so changing "http://" to "wss://" would not work. Could I tunnel the WebSocket protocol through HTTP? If I did, I would probably have to use Ajax, but avoiding that is the reason I wanted a WebSocket chat program.
Blogger has a place where you can insert your own HTML; would it be possible to use PHP tags to delineate the code from HTML?
I would just like to know whether it's possible to do what I want, and if it is, some implementation tips or (even better) some example code to use.
"The server implementation would be inside of a webpage"
A server implementation is not in a web page. Not sure what you meant here. You may want to edit your question.
Node.js is library written in JavaScript for use on the server. Google this and you should find many ways of getting started on running a WebSockets. To connect to the client, you will be using JavaScript as well, which you should again select a library that supports web sockets.
Additionally, you will need to verify the client' Browser supports it.
You can look at browsers that support web sockets here
Here is a jQuery plugin for web sockets

How to use js to control actionscript on another page?

I know it's pretty easy to connect flash and js on one page by using external interface call.
But how would you connect a flash with the js on another page?
For example, if I had a flash game opened on one computer, but the user can only interact with the game with js on another computer. \
Please help.
I don't think you would be able to get these two things to communicate separately without some kind of medium or using XML Sockets. If it doesn't need to be real-time, then consider sending/receiving data to/from a MySQL server. If it does - I know you'll need to look at XML sockets - I'm just not 100% on how they are used as I've never had the resources to experiment.
I don't thinks this is possible. Only using some server-side programming ou multiplayer server, etc.
Using LocalConnection your SWFs can comunicate to each other, but they need to stay in the same page, same user.

Best way to record audio with mic and send to server

I know there are similar questions but there is no answer for me.
What is the best option for recording audio with microphone on website and send to server for some operation.
1) java/javascript
2) red5
3) flash/flex
4) silverlight
5) other(pls specify)
I want to create something like this : http://wami.csail.mit.edu/examples/jsapi/calculator.html
Well, your question isn't exactly a good one. There is no 'best technology', only what's best for your project which I know nothing about.
With that being said, there's also the fact that you're bundling both front end and back end technologies together, which doesn't work. And what kind of 'work' do you need done on the audio.
If it was me, I'd use Flash on the front end to record the microphone since it has the most market penetration compared to say Silverlight. Javascript cannot record the microphone. From there, I can then send the audio (streamed or not) to the server, which in this case is really up in the air. I could be any technology and it wouldn't matter all that much unless one language has a better audio library than the other. If you just want to store the recording, you can use something extremely simple like PHP, but if you need something a bit more robust, you'll probably have a better time with using Java.
How Flash sends the audio to the server is up to you. There are several options but if it doesn't need to be streamed, I'd say just upload using http.
The technology you refer to in your example is open-source. It uses a hidden Flash app to perform an HTTP post from client to server. Streaming is simulated by chunking the audio into multiple POSTs. Here's the link:
https://code.google.com/p/wami-recorder/

Write a serverside c++/openGL App, that is accessible via JavaScript

I am currently having an idea where I want to save an image from a c++/openGL application on demand from a browser. So basically I would like to run the application itself on the server and have a simple communication layer like this:
JS -> tell application to do calculations (and maybe pass a string or some simple data)
application -> tell JS when finished and maybe send a link, text or something as simple as that.
I don't really have alot of experience with webservers and as such don't know if that is possible at all (it's just my naive thinking). And note: I am not talking about a webGL application, I just want to have simple communication between a c++ serverside application, and the user.
Any ideas how to do that?
Thanks alot!
Basically no matter what your language/framework you choose for your web server, you just need a interface that is callable from your browser JS, and you can do whatever you want in the server once it recieves the call.
Most likely any web service interface exposed from the server.
Just need to safeguard your server not to get DoS since it sounds like it's a huge process.
As far as I know, JavaScript (at least when embedded in HTML) is executed on your local machine and not on the server so that there is IMHO no way to directly start your server-application using JS.
PHP for example is executed on the server-side and so you could use e.g. the php system function to call your C++/OpenGL application on the server - initiated on demand through a web-browser.
When the call is finished you could then directly present the image.
Well you could always use the cgi interface to invoke your application
and have it save that image somewhere accessible to the webserver.
Then have your js load that via ajax.
Or make a cgi App that talks to the app and then serves a small
page with the pic in it.
[EDIT]
Answering the comments:
CGI is not complex to learn, it is mostly a simple convention
you can follow. I think it would give you the maximum of
flexibility. I don't know which php mods allow you to leave the cozy protection of the server-application and interact with other stuff on your server.

Categories

Resources