[Red5] Red5 and Ruby on Rails Integration - Interest?
Ngoc Dao
ngocdaothanh at gmail.com
Fri Apr 25 16:51:48 PDT 2008
Very impressive work! That combines strength of both worlds: HTTP of
RoR and RTMP of Red5.
Could you explain in some more detail how you made the connection
between RoR and Red5?
Ngoc.
On Sat, Apr 26, 2008 at 7:18 AM, Matt Hodgson <mhodgson at youcastr.com> wrote:
> Hello all, I started using Red5 a couple weeks ago and I wanted to let the
> community know about a few of the projects I've been doing and guage
> interest for releasing some code as a bundled plugin. First of all, can any
> one point me to any examples of previous Red5 plugins? Is there any such
> thing? Is there a set standard for how to release them? Thanks. Ok, now to
> what I've done: Comming to Red5 from the RoR world, I'm not very familiar or
> comfortable with Flash or Flex. I'm sure they are great once you get used to
> them, but what I really wanted was a way to tightly integrate Red5 wtih RoR.
> I think I've come up with a relatively streamlined solution that could be
> used by others. Here's the basic idea: 1. Set up a non-blocking threaded
> socket server on Red5 as a "back door" into the red5 app. This is much
> faster and easier than trying to implement a web service. 2. Created a RoR
> plugin that can send and receive data to the Red5 socket server. All data
> transfered over the socket is JSON.
> 3. Set up my flash client to Red5 with a simple method that calls the
> ExternalInterface with data passed from Red5 (basically allows for me to
> send javascript to execute on the page).
>
> Now I can do things like this from my RoR controller methods:
>
> render :red5 => {:type => :send_to_channels, :channels =>
> ["scope1_name","scope2_name"]} do |page|
> page.alert "Hello from Rails!"
> end
>
> Any clients connected on the given scopes will see the javascript alert
> message (or whatever else you want to send) since Red5 is passing the data
> to the ExternalInterface call on the clients. Basically the end result is
> one-to-many AJAX-like broadcasting (with the wonderful RoR rjs language).
> Pretty sexy. Now I can do *anything* I can normally do with AJAX, but in a
> live real-time implementation with many users. HTML chat? Done. Live CSS
> Polling? Done. All with only 3 lines of actionscript and a tiny little flash
> client.
>
> In addition, I also borrowed and modified a bunch of code from the admin app
> to create some handy ruby calls for getting data back from the red5 server.
> These include:
>
> Red5.get_data_for_server(server_ip_or_dns)
> This returns a hash with statistics, connection data, and persistence data
>
> Red5.get_data_for_user_on_server(user_id,server_ip_or_dns
> This returns a hash with connection data and and attributes associated with
> the user
>
> Red5.get_user_list_for_server(server_ip_or_dns)
> This returns a hash with a list of both broadcaster, and listener user ids
>
> Red5.get_load_for_server(server_ip_or_dns)
> This returns a small hash with just active connections and active streams
>
> These have been working great and allowed me to create an interactive
> management dashboard using nothing more than simple html.
>
> Anyway, if people think this could be useful to them I'm willing to take
> some time to extract it from my site and bundle it up - along with a blog
> post about how to use it. I can't promise I'll have a ton of time to
> maintain it but at least it will be available.
>
> Enjoying Red5 so far, thanks to all the contributors!
>
> - Matt Hodgson
More information about the Red5
mailing list