[Red5] on client verification.

Andy Shaules bowljoman at hotmail.com
Sun Sep 7 13:05:40 PDT 2008


Hello,

If you are like me and have Lamp powering n Number of servers and need to 
verify an incoming client, how many dev's used the amf php client from the 
service browser that comes with amfphp? I know its been covered before, but 
again I havnt seen too many posts on services, or in particular, a good way 
to send a user-token to a red5 application from a remote Lamp server. Yes, I 
know Im not the first to do this, but as a Faq, I thought I'd share it once 
again.
Verification was just brought up last week.

The idea is that a client will never see the curl post to red5, and you 
control 100% of the php side. :)

 Client->PHP{ cURL(token) to red5}->Red5 is waiting for for client with 
token



Example- Hello world.
(client verification unfortunatly at this moment  is closed-source.)

NOTE: You must enable the remoting servlet in your app's web.xml by adding 
the following.


<servlet>
<servlet-name>gateway</servlet-name>
<servlet-class>
org.red5.server.net.servlet.AMFGatewayServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>gateway</servlet-name>
<url-pattern>/gateway/*</url-pattern>
</servlet-mapping>


This opens up the gateway at http://localhost:5080/yakima/gateway where my 
webapp is named 'yakima'



..in my app start using the IScope, I register the service

scope.registerServiceHandler("test", this);

..and define function :

public String test(Object arg)
{
    return "Hello, world";
}

So, after installing amf php on the Lamp server running the main db 
services, I prepare one of the many red5 servers for a connection.
I send a token from php.
Of course this is just a sample 'hello, world' return, but the idea is the 
same for client verification. Send the token from lamp, save to an array of 
tokens on red5, and wait for thr client to arrive with the match. Then 
remove the token from the que, and place all info into Client Attributes.


Here is the php code for the sample:

<?php
include('client/AMFClient.php');//Comes with amfphp 2.0
$c=new AMFClient("http://localhost:5080/yakima/gateway");
$args=Array
(
);
$s=$c->createRequest("test","test",$args);
$r= $c->doCurlRequest($s);
echo "Results :<br />".$r;

?> 




More information about the Red5 mailing list