Flex FMS应用(下)

四、注意事项

   通常新手在学习FMS的时候都会遇到一个问题,那就是通过NetConnection连接FMS服务器的时候,连接状态总是返回 “NetConnection.Connect.Rejected”这样的状态结果,然后接着还有会有一个 “NetConnection.Connect.Failed”状态,是什么原因造成这样的错误的呢?

   第一个错误从本文实例中你可以得到,是访问FMS服务器的权限问题,如果FMS没有开设足够的访问权限,通常在访问FMS的客户端都会接受到这样一个异 常状态。第二个错误又是怎么产生的呢?这还是又访问权限引起,当客户端没有主够的权限访问FMS服务器,就将返回 “NetConnection.Connect.Rejected”状态并自动断开与FMS服务器的连 接,“NetConnection.Connect.Failed”状态本身是由于连接服务器失败产生,而这里是因为权限问题而引发的。

   前几天很多朋友就在问我这个问题,怎么来解决这个问题呢?如果你是一个技术专研者,如果又你赶兴趣的技术在你面前,你首先会做什么?查看官方提供的文 档?实例代码?还是什么? OK,其实要解决这个问题很简单,在FMS服务器安装好后的目录下有一个"applications"目录,里面有两个FMS默认安装的FMS服务器 (live和vod),随便打开一个默认安装然后打开里面的"readme.txt"文件会看到下面的字样:

================================================================
Deploying an unsigned vod service
================================================================
  
1. Create a new folder in the {FMS-Install-Dir}/applications folder.

2. If you are replacing the default Adobe signed live service, back up
   the following files:
   * main.far
   * Application.xml
   * allowedHTMLDomains.txt
   * allowedSWFDomains.txt

3. Copy files from {FMS-Install-Dir}/samples/applications/vod to the directory you created in step 1.


   现在你知道怎么解决上面出现的问题了吗??将这main.far、Application.xml、allowedHTMLDomains.txt和 allowedSWFDomains.txt这四个文件复制到你创建的FMS服务器目录下就解决了,运行上面的实例程序,然后可以通过FMS的管理控制台 查看到详细的连接信息。

  我通常是使用的FMS安装目录下的fms_adminConsole.swf 来查看连接信息,也可以使用FMSfms_adminConsole.htm查看。


服务器连接设置

attachments/200708/29_150312_5.jpg



Main.asc代码 复制代码
  1. <SPAN style= "COLOR: #c0c0c0" ><SPAN><SPAN><SPAN>application.onConnect=function(client,permission){   
  2. trace(permission);   
  3. if(permission == "admin" ){   
  4.      //服务器同意连接   
  5.      this.acceptConnection(client)   
  6. }else{   
  7.      //服务器拒绝连接   
  8.      //this.rejectConnection(client);   
  9.      application.rejectConnection(client, {msg: "server refuse " +permission+ " connecting !" });   
  10. }   
  11. }   
  12. </SPAN>   
  13.   
  14. </SPAN>   
  15.   
  16. </SPAN>   
  17. </SPAN>  
application.onConnect=function(client,permission){
trace(permission);
if(permission == "admin"){
 //服务器同意连接
 this.acceptConnection(client)
}else{
 //服务器拒绝连接
 //this.rejectConnection(client);
 application.rejectConnection(client, {msg:"server refuse "+permission+" connecting !"});
}
}









Flex代码 复制代码
  1. <SPAN style= "COLOR: #c0c0c0" ><SPAN><SPAN><SPAN>myNetConnection.connect(serverApp, "admin" );</SPAN>   
  2.   
  3. </SPAN>   
  4.   
  5. </SPAN>   
  6. </SPAN>  
myNetConnection.connect(serverApp, "admin");








Flex代码 复制代码
  1. <SPAN style= "COLOR: #c0c0c0" ><SPAN><SPAN><SPAN>switch(evt.info.code)   
  2.                  {   
  3.                      case "NetConnection.Connect.Success" :   
  4.                          trace( "成功连接FMS服务器!" );   
  5.                          break;   
  6.                      case "NetConnection.Connect.Rejected" :   
  7.                          /* 注意这里,服务器拒绝你的情况,如果遭到拒绝,将会调用两次mync.onStatus,   
  8.                           第一次 "NetConnection.Connect.Rejected" 2 "NetConnection.Connect.Closed" */   
  9.                          trace( "遭到服务器拒绝" );   
  10.                          trace( "服务器返回信息:" + evt.info.application.msg);   
  11.                          break;   
  12.                      case "NetConnection.Connect.InvalidApp" :   
  13.                          trace( "指定的应用程序名称没有找到" );   
  14.                          break;   
  15.                      case "NetConnection.Connect.Failed" :   
  16.                          trace( "连接失败!" );   
  17.                          break;   
  18.                      case "NetConnection.Connect.AppShutDown" :   
  19.                          trace( "服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!" );   
  20.                          break;   
  21.                      case "NetConnection.Connect.Closed" :   
  22.                          trace( "与FMS的连接中断!" );   
  23.                          break;   
  24.                  }   
  25. </SPAN>   
  26.   
  27. </SPAN>   
  28.   
  29. </SPAN>   
  30. </SPAN>  
switch(evt.info.code)
    {
     case "NetConnection.Connect.Success":
      trace("成功连接FMS服务器!");
      break;
     case "NetConnection.Connect.Rejected":
      /* 注意这里,服务器拒绝你的情况,如果遭到拒绝,将会调用两次mync.onStatus,
       第一次"NetConnection.Connect.Rejected"第2次"NetConnection.Connect.Closed" */
      trace("遭到服务器拒绝");
      trace("服务器返回信息:" + evt.info.application.msg);
      break;
     case "NetConnection.Connect.InvalidApp":
      trace("指定的应用程序名称没有找到");
      break;
     case "NetConnection.Connect.Failed":
      trace("连接失败!");
      break;
     case "NetConnection.Connect.AppShutDown":
      trace("服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!");
      break;
     case "NetConnection.Connect.Closed":
      trace("与FMS的连接中断!");
      break;
    }












(thanks : http://www.51as.com/fms/fms3jiaochen.html )


相关资料一大把:


Flash Media Server 入门教程

http://www.nshen.net/blog/article.asp?id=509


Flash Media Server 起步(2)连接

http://www.nshen.net/blog/article.asp?id=394


Flash Media Server 起步(3)远程共享

http://www.nshen.net/blog/article.asp?id=395


Flash Media Server 起步(4)视频,流。。。

http://www.nshen.net/blog/article.asp?id=397


Flash Media Server 起步(5)连接的一些细节

http://www.nshen.net/blog/article.asp?id=401


Flash Media Server 起步(6)写个简单的聊天室

http://www.nshen.net/blog/article.asp?id=403


Flash Media Server 起步(9)在线列表。。

http://www.nshen.net/blog/article.asp?id=409


Flash Media Server 起步(10)中文编码问题

http://www.nshen.net/blog/article.asp?id=414


Flash Media Server 起步(11)判断影片结束

http://www.nshen.net/blog/article.asp?id=415


http://www.cnblogs.com/aierong/archive/2009/01/09/flex_fms_chat.html


http://www.51as.com/fms/fms-1.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值