views:

372

answers:

2

I'm a bit confused. I would like to send messages from my Red5 Server to my Flash App... but I don't find any information how to do that...

Can anyone help me?

A: 

This looks like a good start: http://www.red5tutorials.net/index.php/Tutorials:Getting_Started_With_Red5_Server

See near the bottom for their simple flash client.


Edit: More options given now that it's clear we're going from server-client:

Looks like you need to do something like this: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetConnection.html

and

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html

which would mean using "NetStream.play()" to get the server to stream data to the client.

Or you might want to look at the Socket class(es) and manually create a direct socket connection between the client and server.

Keep in mind here, I've never used Red5. Just trying to help :)

Glenn
:/ This is the way from Flash to Red5... I need it the other way ;) Red5 -> Flash And also not the Method-Return-Value-Way..
Hank
A: 

Hmm, by definition, the server serves and the client requests. So to create a push scenario, you still have to first initialize a connection from the client to the server. Then you can leave the connection idle until you need to send something to the client. Polling is the other method, where the server holds on to the messages and the client frequently checks in to see if new messages are available. A server cannot initiate a connection to the client. That would make the client a server. In other words, you could have the flash client register it's current IP with the server and open up a port itself, establishing itself as a server. Then the Red5 server becomes a client and can connect to the server inside the flash client. But I imagine many security restrictions will prevent your flash program from acting as a server in the real world.

Killroy
hmmm I just want to notify the client that some job is done... but I can't return some "yeah awesome I did it" in the same method (that would work) so I need to notify the client later...
Hank
Sounds like you want polling. Depending on how long these tasks take, you could have your client check back with the server every second/minute/hour/day to see if the job has been done. Or you could keep a connection from the server to the client, with the client simply waiting for the response code from the server, but with a timeout, just in case.
Killroy
yeah :) finally solved it that way... ;)
Hank