How to customize stream protocol to flash client - actionscript-3

I need to create a custom communication between server and flash client. For example I want to write UDP protocol using error correction. It is much faster than TCP and does not suffer from routing problem. Unfortunately I absolutely cannot think of how to replace the existing way:
_stream = new NetStream(_connection);
_video.attachNetStream(_stream);
This encloses all communication and I do not have a control over it. I understand that I can use appendBytes, but not sure what exactly to pass to this function. I can do anything on the server side. My video is H.264 and audio is ACC.

Unless it's a AIR application, you can't. It's native API which already handling application layer (OSI model).
If you want make your own, using flash.net.DatagramSocket class (available in AIR 2+) for your application layer and NetStream.appendBytes for audio/video stream decoding & playback (feeded with FLV/F4V chunks)
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/DatagramSocket.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#appendBytes%28%29

I was betting on UDP, but never got it working in Flash. I'll explain it:
In your browser, there is really no way to make usage of UDP!!! Flash applications there run in a sandbox, which only talk TCP!
Air is used for desktop applications, which after compilation run in a desktop wrapper, which itself has direct access to the socket and other possibilities.
That's it! You have to use TCP.

Related

Available Functions on FMS Server

I have a chat client that uses FMS server. I do not know how many more functions are on FSM that I can utilize. There is 0 documentation for the available FMS server. Is there a way to browse or query all the available features/functions of Adobe FMS server?
Also some of the chatters crashes my flash play remotely. I think, they are just overflowing the buffer? Is it the case? or how anyone can remotely crash my flash player? This only happens if I kick any of the specific user using the command /kick user.
FMS has pretty good doc at FMS API. But functions you want depend of who implemented server side for you.
Crash might be caused of your chat implementation. You need to find initial developer to fix that.

Turn off application temporarily from flash

I have been asked to figure out a way to turn off a running application on a host computer when i certain flash application is running in the browser, a seemingly difficult task but i have thought of a few possible ways to achieve this and i would like to ask which approach would be the best.
The way i see it these are my possibilities
Have the flash application create a cookie which another program checks for and if detected, this program running on the computer will then turn off the other application.
Have a program running on the host computer listening on a specific port and when the proper string is sent fx. through the use of actionscript sockets, the program will turn off the application temporarily.
Create a program sniffing network traffic and if the swf in question is being downloaded, turn off the other application temporarily (This seems to me to be the least viable approach, not even sure it would be possible to do effectively)
The reason i need to do this, is because the flash application will need to access the webcamera of the host computer, which doubles as a motion detecting camera which means the camera will be locked while the motion detection software is running. So i need to turn off the motion detection software, grab a picture in flash, save the picture and start up the motion detection again.
Am i missing some super simple approach? how would you achieve this? Thanks in advance for your answers.
TBH I don't think you'll succeed in this, unless you create it as an Air app (granted, I didn't spend too much brain power on thinking up solutions). The flash player is very restricting on what you can and cannot do. ExternalInterface is the replacement of FSCommand, which is considered obsolete, BTW. It allows you to communicate from AS with the swf container. JS (and maybe VBScript?) only though.
However, if it turns out you need to create an Air app, you can use NativeProcess which allows you to run an application on the host. For instance, if you'd want to run a java .jar you could do this:
var javaExecutable : File = new File();
javaExecutable.nativePath = '/path/to/java/';
var processArguments : Vector.<String> = Vector.<String>([
'-jar',
'/path/to/jar/',
'foo'
]);
var process : NativeProcessStartupInfo = new NativeProcessStartupInfo();
process.executable = javaExecutable;
process.arguments = processArguments;
var shell : NativeProcess = new NativeProcess();
shell.addEventListener(NativeProcessExitEvent.EXIT, onExitEvent);
shell.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStdOutputDataEvent);
shell.start(process);
Very important to note: (emphasis mine)
The NativeProcess class and its capabilities are only available to AIR applications installed with a native installer (extended desktop profile applications).
You can also use the fscommand() function to pass messages to Director
or to Visual Basic, Visual C++, and other programs that can host
ActiveX controls.
in FSCommand

whats the difference between stratus and flash media server 4

I want to create a simple video chat application using rtmfp the new p2p feature. It's available in flash media server 4 and using stratus, I've only been able to find tutorials on stratus. So my question is if I want to use the p2p feature in flash media server 4 do I have to signup for stratus and use its api or does fms 4 have its own api?
What is your goal? If you need to make just a videochat, you can use FMS only, without stratus. Just connect to server, perform connection accept on serverside, and then you can use publish and play methods of NetStream class. But if you want to perform videochat through p2p, than you do not need FMS (because the main idea of p2p - communication without server), but still you can use FMS for managing clients, and perform video streaming through stratus.

Adobe AIR application as a http server?

Is there any way to use an Adobe AIR application as a local http server? i.e. Adobe AIR application listening to http://localhost:8020 and I'm able to use a browser to access the application? If I can, is it true or pseudo multithreading?
Is there any library or code that I can look for?
The ability to listen to ports is a new feature in AIR 2, which ought to release soon but is currently in beta. If you're using version 2 though, you could certainly create an HTTP server if you want to. A general example of building a socket server can be found here.
Note that AIR apps are event-driven, not threaded. You can of course deal with multiple connections, so I suppose the runtime itself is driving them in different threads, but the code you write doesn't deal with threading or blocking, you just register for events on connection, data, etc. and handle them. (That may be what you mean by psuedo-threaded, I'm not really up on such things.)
However, there is a very big caveat to this, which is that AIR is not currently recommended by Adobe for headless server-like applications. As I understand it, there could be cases where the runtime popped up a confirmation dialog, and some things about the app might not work correctly until you remoted into the server to dismiss the dialog.
You can use HTML Control for that.
<mx:HTML width="100%" height="100%" id="html" x="0" y="0" location="http://localhost:80/"/>

Anyone know about Rhomobile?

I read about http://rhomobile.com/ and I found this is great but I want to ask whether the application built with that would run in Browser or Natively on the device as this requires HTML and Ruby?
The application generated using Rhodes are pure Native application... And there is no need to install Ruby on devices as Rhodes will take core of it..
May be this URl is helpful :
http://itsallaboutruby.blogspot.com/2010/08/rhodes-framework.html
Abhishek
Both, actually.
Your application is a web application, but it doesn't run on the internet, it runs on a small webserver that is part of your application inside the phone. It also doesn't run in the browser, but rather in a native browser widget inside your application.
Since the webserver runs on the phone itself, it has access to all the native capabilities of the phone, so you can make HTTP calls to the webserver to capture sound from the microphone, shoot video with the camera, get the GPS location, get multitouch info and so on.