民浩

 

[转载]FMS Dev Guide学习笔记(验证用户)

一、开发交互式的媒体应用程序

1.使用外部资源验证用户

    对于有限数量的客户,请求用户名密码,然后通过外部资源(像数据库、LDAP服务或其它访问授权服务)验证它们,是可行的.

    a.SWF在请求连接的时候提供用户名和密码

    通过客户端Actionscript,客户端提供token或者用户名和密码:

var sUsername = "someUsername";
var sPassword = "somePassword";

nc.connect("rtmp://server/secure1/", sUsername, sPassword);

    b.FlashMediaServer通过第三方系统验证用户名和密码

你可以使用如下类来从服务端Actionscript访问外部资源:WebService、LoadVar、XML classes、NetServices(Flash Remoting).参见Server-Side ActionScript Language Reference以获取更多关于这些类的信息.关于FlashRemoting请参见http://www.adobe.com/go/learn_fms_flashremoting_en.

load("NetServices.asc");     // for Flash remoting
load("WebServices.asc");     // for SOAP web services

pendingConnections = new Object();

application.onConnect = function( pClient, pUsername, pPassword ) {

    // create a unique ID for the client
    pClient.FMSid = application.FMSid++;

    // place the client into a pending array
    pendingConnections[FMSid] = pClient;

    if (pUsername!= undefined && pPassword !=undefined) {
        // issue the external call (3 examples below)
        loadVars.send("http://xyz.com/auth.cfm");

        webService.authenticate(FMSid, pUsername, pPassword);

        netService.authenticate(FMSid, pUsername, pPassword);
    }

// the result handler (sample only, you will have to customize this)
// this command will return a true/false and the FMS client id
Authenticate.onResult = { }

    c.FlashMediaServer接受或者禁止这个连接

    loadVars.onData = function ( FMSid, pData ) {
    if (pData) {
        application.acceptConnection( pendingConnections[FMSid] );
        delete pendingConnections[FMSid];
    } else {
        application. rejectConnection ( pendingConnections[FMSid] );
    delete pendingConnections[FMSid];
    }
}

posted on 2013-12-11 16:22  民浩  阅读(289)  评论(0编辑  收藏  举报

导航