Simple Red5 X Flash AS3 Comunication Example (Send Strings) - actionscript-3

I searched the web but can't find a simple example for sending strings to a server red5 RTMP, using an as3 (flash ide-compiled).
where can I find a tutorial about this?

Your question is fairly broad, but I can direct you to an old blog post of mine that gives examples of how to send AS3 Vectors. This may help you with how to perform communication with the server. http://blog.infrared5.com/2011/08/red5-vector-support/

You can send Strings or any Custom Objects by following this tutorial : Custom Object
Communication from as3 client to red5 server can be done by using the call method of netconnection as described in Application handlers part.
On Server side
public void myFunc(String myString) {
//do work
}
On Client side
nc.call("myFunc", null, "Hello World");

Related

Firebase: What is being done behind the onDisconnect method? (AS3)

First, I want to mention, I understand how the Firebase onDisconnect method works in JavaScript. It tells the server what to do once the user is disconnected, in advance.
Now, I am using AS3. How should I tell the server the same thing as achieved by the 'onDisconnect' method?
When I tried debugging the code in JavaScript, it doesn't seem to send something to the server.(or maybe i am wrong).
Sample code in JavaScript:
userRef.on('value', function(snapshot) {
if (snapshot.val()) {
userRef.onDisconnect().remove(); //this line does the magic
}
});
What is being done by the onDisconnect method which tells the server what to do? What is the equivalent code if written in AS3?
EDITED:
The code in AS3, as reference by here, it works for Realtime Database.
private var myStream:URLStream;
private function loadLiveFeed():void
{
var header:URLRequestHeader = new URLRequestHeader("Accept", "text/event-stream");
var request:URLRequest = new URLRequest("https://<YOUR-PROJECT-ID>.firebaseio.com/breakingnews.json");
request.requestHeaders.push(header);
myStream:URLStream = new URLStream();
myStream.addEventListener(ProgressEvent.PROGRESS, progress);
myStream.load(request);
}
private function progress(event:ProgressEvent):void
{
var message:String = myStream.readUTFBytes(myStream.bytesAvailable);
trace(message);
}
The code you shared accesses the Firebase Database through its REST API:
new URLRequest("https://<YOUR-PROJECT-ID>.firebaseio.com/breakingnews.json");
This means that it is using a connectionless method to interact with the database. Unfortunately that also means that there is no way to register an onDisconnect() handler, since it would essentially have to fire between any two HTTP calls that you make.
No time to answer this, but you'd have to reverse engineer the communication. Under the hood, it's all just HTTP (or similar) as can be seen in the As3 code. To know what's going on exactly, get a working example code in JavaScript that contains the magic line you are curious about, then execute it in the browser. All requests can be monitored in the developer tools of the browser. You should be able to identify what's being sent.
Also, it's JavaScript, which means you have to have the source code which you can simply read. It might be minified and/or obfuscated, but maybe you can find a readable one.
With the knowledge of what the bare requests look like, you can then implement an API of your own in any language that's capable of performing the necessary network communication.

How to add CuePoint to a rtmp stream with ActionScript 3.0

I am trying to build a teaching application using flash player. My idea is that when the teacher does something, such as changing the slides, the javascript calls the SWF interface which adds CuePoints to the rtmp stream, while the students listening on the CuePoint event, they are able to synchronize what the teacher is doing.
So I did my research and found out that I had to write some server-side script/module to support this. I tried Wowza Server and wrote a Java Module which defined a handler function so the AS was able to call
netconnection.call("handler_function", null, "myStream", arg1, arg2);
But sadly, I am using a third-party streaming cloud so I can't write server-side code. Is there any way to add the CuePoint only on the client side with ActionScript?
Dont have enough to mark a comment so posting it here. I did not use FMS/wowza recently, but using FMS I used to do this like the example at https://forums.adobe.com/thread/1152718?tstart=0
hope this will work same on wowza too. Thanks

Can an embedded cocos2d-js app call back out to c++?

I'm researching the possibility of using cocos2d-js by embedding it as a view inside an existing iOS app. In order to make this work, I'm going to need 2-way communication between cocos2d and the surrounding application.
After some initial investigation, I have determined that it is possible to call in to cocos using ScriptingCore:
ScriptingCore* sc = ScriptingCore::getInstance();
jsval outVal;
sc->evalString("function()", &outVal);
My question, then, is around doing the reverse. It is possible to (e.g. in response to user input) call back out of cocos2d-js to C++? Ideally, there would be a way to register a callback with ScriptingCore which could be invoked from JavaScript.
I believe it can be done, but I have not tried myself, nor can I find a good and concise example.
All I can do is point you at SuperSuraccoon's Bluetooth example and it's git page, which apparently does both ways communication between C++ and JS code.

How can AS3 front-end code and AS2 server-side scripting send objects back and forth, while keeping their methods?

Given the following AS3 front-end code:
m_nc.connect("rtmp://" + pPrimaryIP + "/appname/"+ pVID, pUID, pConfig);
and the following AS2 server-side scripting code:
application.onConnect = function(pClientObj, pUID, pConfig)
{
// do stuff
}
where pConfig is an object of type Configuration, as defined in the AS3 code, having the method:
public function copy(pConfig:Configuration):void
apparently when you try to send the object across while connecting, it loses that method and any other methods. Yet its fields remain basically intact, at least if they're primitives. I can see why this might be so, but is there not some way to keep this loss from happening? I really want to be able to not just send it to the AS2 without losing anything, but to also be able to send it back to the AS3 without losing anything. Is this possible? If so how? Thanks!
You should look at LocalConnection, a class available to both AS2 as AS3 (AS1 even)
clicky

Websocket and Java Swing front end

Is it doable to make Websocket interfaced with Java Swing front end? If so how?
Try mine:
http://github.com/TooTallNate/Java-WebSocket
Contains a Client and Server implementation. In the example folder there's a simple JFrame subclass called ChatClient. Look at it's source for a Swing reference.
Essentially you just need to subclass net.tootallnate.websocket.WebSocketClient and implement the onOpen, onClose, and onMessage methods. The class has an interface very similarly to the WebSockets API for HTML5.
Kaazing WebSocket Gateway ships with support for JavaScript, Flex, Silverlight, but also native Java clients (stand alone as well as applets). For more information, check out
http://tech.kaazing.com/documentation/index.html