首页 > 其他 > 详细

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

时间:2015-07-16 13:26:37      阅读:116      评论:0      收藏:0      [点我收藏+]

 

 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 }

 

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

原文:http://www.cnblogs.com/frost-yen/p/4650622.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!