Red5 Remoting



Remoting a facility by which a client can call a server method in a  request response fashion. Unlike RTMP remoting services are performed using AMF over HTTP/HTTPS. Red5 can act as both a RTMP server as well as a HTTP/HTTPS remoting server. Remoting enables non rtmp clients to access Red5 methods.  A very practical approach would be to request chat room user count for example. Using remoting you can request such data without consuming too much server resources as in a RTMP connection. You can also create chat programs with simple amf-polling as well. Remoting also lets you sync data types over both ends (client-server)

In this article we will see how to consume services on Red5 using remoting. You may want to refer red5.org about a few important things.

Creating a basic service class:

Though i wont be explaining how to create a Red5 application here, and i assume you already know that before starting off with remoting , still we will see the basic of setting it all up, as it includes creating a basic application as well.

Step 1: – Launch Eclipse

Eclipse Galileo

Eclipse

Note: Use only J2EE version of eclipse when working in Red5 with Red5 plugin for best results.

Step 2:  - Create a basic Red5 application called “remotingdemo.

(you can follow the Red5 developer series by Dominick Accattato on youtube to get started with Red5 basics)

New-Red5-Project - 'remotingdemo'

New Red5 Project

Step 3:  - Create a service class. This class will hold our methods for remoting. Red5 maintain tight security by not allowing the client to call just any method on the server. You must register the class as  service handler before you expose it to client. So here for our example we create a class called RemoteMethods and this class will implement the IServiceHandlerProvider interface found at org.red5.server.api.service.IServiceHandlerProvider.

Red5-Service-Class

The Service Class

Step 4:  -  Register this class as a service handler. Now that we have create our class that will hold service methods, we need to expose it to our client.  Red5 allows us to do this in 2 ways.

  • Expose the class as a service handler by defining it as a Bean in the red5-web.xml
  • Expose the class as a service handler by registering it in the application code itself.

For our purpose we will be looking at the second way of  exposing services. However in the end i will show you how we use the first method as well. To understand handlers better you can refer to red5.org here.

So to register this class as a service handler, we will implement the appStart() method in our Red5 application and register it there.

/** {@inheritDoc} */
@Override
public boolean appStart(IScope app)
{
Object handler = new org.red5.core.RemoteMethods();
app.registerServiceHandler("RemoteClass", handler);
return true;
}

Note: When using registerServiceHandler, you may need the spring-core-2.5.6.jar file from red5 lib directory.

So as you see in the snippet above , that’s what out appStart will look like finally. We have registered the class that we created – “RemoteMethods” in the root scope of our application and it will be referenced as “RemoteClass. This hides the actual class name.

Popularity: 36% [?]



Pages: 1 2


August 3, 2010  Tags: , , , ,   Posted in: Java, Red5

25 Responses

  1. Watch March Madness Online - March 8, 2011

    Watching March Madness Online…

    [...] You can leave a response, or trackback from your personal website. Learn more via the original source: Check out March Madness 2011: « March Madness weblog Share and [...]…

  2. ripped abs - March 9, 2011

    Steve’s Super Site…

    [...] You may leave a reply, or trackback from your personal webpage. Read much more from the original source: How to Get Ripped: « Ripped Abs weblog Share and [...]…

  3. Airline Tickets - March 10, 2011

    Airline Tickets…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  4. Australorps Chicken - March 10, 2011

    Appenzeller Spitzhauben Chicken…

    [...]Sites of interest we have a link to[...]…

  5. Pepper Mints - March 10, 2011

    Quite the read…

    [...]very interesting commonality to our prior article… But be critical on resources[...]…

  6. Dentists Perth - March 13, 2011

    Sometimes you come across someones info taht you just need to share…

    Great blog entry, head over and check it out…

  7. margarita maker machine - March 14, 2011

    margarita maker machine…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  8. 6-week body makeover - March 14, 2011

    6 week body makeover…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  9. get gold cash - March 14, 2011

    Get Cash For Gold…

    [...]below you’ll find the link to some great sites that we believe you should visit[...]…

  10. Sensa Trial - March 14, 2011

    Sensa Scam…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  11. local mobile monopoly - March 16, 2011

    local mobile monopoly…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  12. how to get abs fast - March 16, 2011

    how to get abs fast…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  13. new fat loss foods - March 16, 2011

    Amazing site…

    [...]the time to read or visit the content or sites we have linked to below the[...]…

  14. Buy Lingerie - March 16, 2011

    Sometimes you come across someones info taht you just need to share…

    Great blog entry, head over and check it out…

  15. Boat Sales - March 17, 2011

    Sometimes you come across someones info taht you just need to share…

    Great blog entry, head over and check it out…

  16. Mens Watches - March 21, 2011

    thomas sabo jewellery…

    [...]the time to read or visit the content or sites we have linked to below the[...]…

  17. SEO Perth - March 21, 2011

    Sometimes you come across someones info taht you just need to share…

    Great blog entry, head over and check it out…

  18. double strollers - March 23, 2011

    restaurant furniture…

    [...]Check out these sites[...]…

  19. Tucson Personal Injury Attorney - March 24, 2011

    Find an Attorney…

    [...]just below you’ll see the link to several sites that we suggest you could go to[...]…

  20. Corfu travel guide - March 26, 2011

    Corfu island…

    Very interesting info, especially about Corfu…

  21. Conveyancing Solicitors - March 29, 2011

    Conveyancing Solicitors…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  22. Property Solicitors - March 30, 2011

    Conveyancing Solicitors…

    [...]below you’ll find the link to some sites that we think you should visit[...]…

  23. Scary Maze Game - March 31, 2011

    Play Scary Maze…

    [...]here are some other site that might interest you[...]…

  24. The 4 Elements - April 5, 2011

    Earth Water Fire Air…

    Another good post I found which you’ll probably be…

  25. Ronner - June 14, 2011

    Can you explain why you have ResultEvent and FaultEvent imported when they are never used? And for the life of me I can never seem to get it to trigger the FaultHandler, no matter what I do on the server. I would imagine that if I threw an error on the server, it would end up in the FaultHandler but it doesn’t. It actually ends up in a NetStatusEvent with “Netconnection.Call.Failed”. I can’t seem to get seperate calls to go to their respective seperate result and fault handlers.

    I opened up a forum post at http://www.red5.org/forums/topic/104-red5-remoting-result-and-fault-handlers/ as well, but nobody seems to respond.

    Is this tutorial just scratching the surface of remoting and can you end up with individual result and fault handlers on a per call basis? (similar to how mx:RemoteObject works) or is this simply not possible with Red5?

Leave a Reply