[ActionSprit 3.0] FMS服务器带宽检测

 

 1 package {
 2 
 3     import flash.display.Sprite;
 4     import flash.net.NetConnection;
 5     import flash.events.NetStatusEvent;
 6     import flash.events.AsyncErrorEvent;
 7 
 8     /**
 9      * @author Frost.Yen
10      * @E-mail 871979853@qq.com
11      * @create 2015-7-16 上午10:02:15
12      *
13      */
14     public class BandwidthCheck extends Sprite
15     {
16         private var _nc:NetConnection;
17 
18         public function BandwidthCheck()
19         {
20             _nc = new NetConnection();
21             _nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
22             _nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
23             _nc.client = new Client();
24             _nc.connect("rtmp://localhost/bandwidthcheck");
25         }
26 
27         public function netStatusHandler(event:NetStatusEvent):void
28         {
29             trace(event.info.code);
30             switch (event.info.code)
31             {
32                 case "NetConnection.Connect.Success":
33                     // 调用服务器上的本地带宽检测代码。您不需要编写任何服务器端代码。
34                     _nc.call("checkBandwidth", null);
35                     break;
36             }
37         }
38         
39         public function asyncErrorHandler(event:AsyncErrorEvent):void
40         {
41             
42         }
43     }
44 }
45 
46 
47 class Client {
48     public function onBWCheck(... rest):Number {
49         return 0;
50     }
51     public function onBWDone(... rest):void {
52         var bandwidthTotal:Number;
53         if (rest.length > 0){
54             bandwidthTotal = rest[0];
55             trace("Bandwith from server to client is: " + bandwidthTotal + " Kbps");
56         }
57     }
58 }

 

转载于:https://www.cnblogs.com/frost-yen/p/4650622.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值