[转载]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];
}
}
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· C# 13 中的新增功能实操
· Ollama本地部署大模型总结
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(4)
· 卧槽!C 语言宏定义原来可以玩出这些花样?高手必看!
· langchain0.3教程:从0到1打造一个智能聊天机器人