zoukankan      html  css  js  c++  java
  • [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 }
  • 相关阅读:
    别用言语考验底线
    QQ登陆接口
    cookie设置今日不提醒功能
    Sublime Text 3常用插件
    浏览器的标准模式与怪异模式的设置与区分方法
    JS中offsetTop、clientTop、scrollTop、offsetTop各属性介绍
    javascript中闭包的工作原理
    javascript判断图片是否加载完成方法整理
    社会十二效应法则
    小故事
  • 原文地址:https://www.cnblogs.com/frost-yen/p/4650622.html
Copyright © 2011-2022 走看看