home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 136 / MOBICLIC136.ISO / pc / DATA / HOTE / libs / amfphp / amfphp.swf / scripts / __Packages / mx / remoting / debug / ConnectionMixin.as next >
Text File  |  2011-07-20  |  7KB  |  216 lines

  1. class mx.remoting.debug.ConnectionMixin extends Object
  2. {
  3.    static var _attached = false;
  4.    function ConnectionMixin()
  5.    {
  6.       super();
  7.    }
  8.    static function initialize()
  9.    {
  10.       var _loc1_ = mx.remoting.Connection.prototype;
  11.       var _loc2_ = mx.remoting.debug.ConnectionMixin.prototype;
  12.       if(!_loc1_.netDebugProxyFunctions)
  13.       {
  14.          _loc1_.netDebugProxyFunctions = true;
  15.          _loc1_.realConnect = _loc1_.connect;
  16.          _loc1_.realCall = _loc1_.call;
  17.          _loc1_.realClose = _loc1_.close;
  18.          _loc1_.realAddHeader = _loc1_.addHeader;
  19.          _loc1_.connect = _loc2_.netDebugProxyConnect;
  20.          _loc1_.call = _loc2_.netDebugProxyCall;
  21.          _loc1_.close = _loc2_.netDebugProxyClose;
  22.          _loc1_.addHeader = _loc2_.netDebugProxyAddHeader;
  23.          _loc1_.attachDebug = _loc2_.attachDebug;
  24.          _loc1_.sendDebugEvent = _loc2_.sendDebugEvent;
  25.          _loc1_.sendServerEvent = _loc2_.sendServerEvent;
  26.          _loc1_.sendClientEvent = _loc2_.sendClientEvent;
  27.          _loc1_.addNetDebugHeader = _loc2_.addNetDebugHeader;
  28.          _loc1_.updateConfig = _loc2_.updateConfig;
  29.          _loc1_.getNetDebug = _loc2_.getNetDebug;
  30.          _loc1_.isRealTime = _loc2_.isRealTime;
  31.          _loc1_.setupRecordSet = _loc2_.setupRecordSet;
  32.          _loc1_.setDebugId = _loc2_.setDebugId;
  33.          _loc1_.getDebugId = _loc2_.getDebugId;
  34.          _loc1_.getDebugConfig = _loc2_.getDebugConfig;
  35.          _loc1_.trace = _loc2_.trace;
  36.          return true;
  37.       }
  38.       return false;
  39.    }
  40.    function attachDebug()
  41.    {
  42.       var _loc1_ = this;
  43.       if(!mx.remoting.debug.ConnectionMixin._attached)
  44.       {
  45.          mx.remoting.debug.ConnectionMixin._attached = true;
  46.          _loc1_._headerAdded = false;
  47.          _loc1_._configured = false;
  48.          _loc1_._config = new mx.remoting.debug.NetDebugConfig();
  49.          mx.utils.ObjectCopy.copyProperties(_loc1_._config,_loc1_.getNetDebug().getConfig());
  50.          _loc1_._protocol = "none";
  51.          _loc1_._id = String(_loc1_.getNetDebug().addNetConnection(_loc1_));
  52.       }
  53.    }
  54.    function sendDebugEvent(eventobj)
  55.    {
  56.       var _loc1_ = this;
  57.       var _loc2_ = eventobj;
  58.       _loc2_.protocol = _loc1_._protocol;
  59.       _loc2_.debugId = _loc1_._id;
  60.       return _loc1_.getNetDebug().onEvent(_loc2_);
  61.    }
  62.    function sendServerEvent(eventobj)
  63.    {
  64.       eventobj.movieUrl = unescape(_root._url);
  65.       if(this.sendDebugEvent(eventobj))
  66.       {
  67.       }
  68.    }
  69.    function sendClientEvent(eventobj)
  70.    {
  71.       var _loc1_ = this;
  72.       if(_loc1_._config.m_debug && _loc1_._config.client.m_debug)
  73.       {
  74.          if(_loc1_._config.client.http && _loc1_._protocol == "http" || _loc1_._config.client.rtmp && _loc1_._protocol.substr(0,4) == "rtmp")
  75.          {
  76.             if(_loc1_.sendDebugEvent(eventobj))
  77.             {
  78.             }
  79.          }
  80.       }
  81.    }
  82.    function addNetDebugHeader()
  83.    {
  84.       var _loc1_ = this;
  85.       if(!_loc1_._headerAdded)
  86.       {
  87.          _loc1_._headerAdded = true;
  88.          if(_loc1_._config.m_debug && _loc1_._config.app_server.m_debug && _loc1_._protocol == "http")
  89.          {
  90.             _loc1_.realAddHeader("amf_server_debug",true,_loc1_._config.app_server);
  91.          }
  92.          else
  93.          {
  94.             _loc1_.realAddHeader("amf_server_debug",true,undefined);
  95.          }
  96.       }
  97.    }
  98.    function updateConfig(config)
  99.    {
  100.       var _loc1_ = this;
  101.       var _loc2_ = config;
  102.       _loc1_.attachDebug();
  103.       if(_loc2_ == null && !_loc1_._configured)
  104.       {
  105.          _loc1_._configured = true;
  106.          _loc2_ = mx.remoting.debug.NetDebugConfig.getRealDefaultNetDebugConfig();
  107.       }
  108.       mx.utils.ObjectCopy.copyProperties(_loc1_._config,_loc2_);
  109.       _loc1_._headerAdded = false;
  110.    }
  111.    function isRealTime()
  112.    {
  113.       return this._protocol.substr(0,4) == "rtmp";
  114.    }
  115.    function setupRecordSet()
  116.    {
  117.       var _loc1_ = this;
  118.       _loc1_.attachDebug();
  119.       _loc1_._config.client.http = _loc1_._config.client.recordset;
  120.    }
  121.    function netDebugProxyConnect()
  122.    {
  123.       var _loc1_ = this;
  124.       var _loc2_ = arguments;
  125.       _loc1_.attachDebug();
  126.       var _loc3_ = _loc2_[0].substr(0,4);
  127.       if(_loc3_ == "http" || _loc3_.substr(0,4) == "rtmp")
  128.       {
  129.          if(_loc2_[0].charAt(4) == ":")
  130.          {
  131.             _loc1_._protocol = _loc3_;
  132.          }
  133.          else
  134.          {
  135.             _loc1_._protocol = _loc2_[0].substr(0,5);
  136.          }
  137.       }
  138.       else
  139.       {
  140.          _loc1_._protocol = "http";
  141.       }
  142.       _loc1_.sendClientEvent(new mx.remoting.debug.events.NetDebugConnect(_loc2_));
  143.       if(_loc1_.isRealTime())
  144.       {
  145.          _loc1_._connectString = _loc2_[0];
  146.          _loc1_.getNetDebug().sendCommand(new mx.remoting.debug.commands.StartRTMPTrace(_loc2_[0]));
  147.          var ret = _loc1_.realConnect.apply(_loc1_,_loc2_);
  148.          _loc1_.realCall("@getClientID",new mx.remoting.RTMPClientIDResponse(_loc2_[0],_loc1_));
  149.          return ret;
  150.       }
  151.       return Boolean(_loc1_.realConnect.apply(_loc1_,_loc2_));
  152.    }
  153.    function netDebugProxyCall()
  154.    {
  155.       var _loc1_ = this;
  156.       var _loc2_ = arguments;
  157.       _loc1_.attachDebug();
  158.       _loc1_.sendClientEvent(new mx.remoting.debug.events.NetDebugCall(_loc2_));
  159.       _loc1_.addNetDebugHeader();
  160.       if(_loc1_._config.app_server)
  161.       {
  162.          _loc2_[1] = new mx.remoting.debug.NetDebugResponseProxy(_loc1_,_loc2_[1]);
  163.          return Boolean(_loc1_.realCall.apply(_loc1_,_loc2_));
  164.       }
  165.       return Boolean(_loc1_.realCall.apply(_loc1_,_loc2_));
  166.    }
  167.    function netDebugProxyClose()
  168.    {
  169.       var _loc1_ = this;
  170.       _loc1_.attachDebug();
  171.       _loc1_.sendClientEvent(new mx.remoting.debug.events.NetDebugClose());
  172.       if(_loc1_.isRealTime())
  173.       {
  174.          _loc1_.getNetDebug().sendCommand(new mx.remoting.debug.commands.StopRTMPTrace(_loc1_._connectString,_loc1_._clientId));
  175.       }
  176.       var _loc2_ = _loc1_.realClose();
  177.       _loc1_.getNetDebug().removeNetConnection(_loc1_);
  178.       return _loc2_;
  179.    }
  180.    function netDebugProxyAddHeader()
  181.    {
  182.       var _loc1_ = this;
  183.       _loc1_.attachDebug();
  184.       _loc1_.sendClientEvent(new mx.remoting.debug.events.NetDebugAddHeader(arguments));
  185.       return Boolean(_loc1_.realAddHeader.apply(_loc1_,arguments));
  186.    }
  187.    function setDebugId(id)
  188.    {
  189.       this.attachDebug();
  190.       this._id = id;
  191.    }
  192.    function getDebugId()
  193.    {
  194.       this.attachDebug();
  195.       return this._id;
  196.    }
  197.    function trace(traceobj)
  198.    {
  199.       var _loc1_ = this;
  200.       _loc1_.attachDebug();
  201.       if(_loc1_._config.m_debug && _loc1_._config.client.m_debug && _loc1_._config.client.trace)
  202.       {
  203.          _loc1_.sendDebugEvent(new mx.remoting.debug.events.NetDebugTrace(traceobj));
  204.       }
  205.    }
  206.    function getDebugConfig()
  207.    {
  208.       this.attachDebug();
  209.       return this._config;
  210.    }
  211.    function getNetDebug()
  212.    {
  213.       return mx.remoting.debug.NetDebug.getNetDebug();
  214.    }
  215. }
  216.