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

  1. class mx.remoting.debug.GlobalLocalConnection extends Object
  2. {
  3.    function GlobalLocalConnection(isController, receiver, domainName)
  4.    {
  5.       var _loc2_ = this;
  6.       var _loc3_ = _global;
  7.       super();
  8.       _loc2_.maxConnections = 10;
  9.       var sToMovie = "_NetDebugLocalToDebugMovie";
  10.       var sToController = "_NetDebugLocalToController";
  11.       var connectname = null;
  12.       if(isController)
  13.       {
  14.          connectname = sToController;
  15.          _loc2_.sendNames = new Array();
  16.          _loc2_.sendNames.push(sToMovie);
  17.          var _loc1_ = 0;
  18.          while(_loc1_ < _loc2_.maxConnections)
  19.          {
  20.             _loc2_.sendNames.push(sToMovie + _loc1_);
  21.             _loc1_ = _loc1_ + 1;
  22.          }
  23.          _loc2_.maxConnections = 0;
  24.       }
  25.       else
  26.       {
  27.          connectname = sToMovie;
  28.          _loc2_.sendNames = new Array();
  29.          _loc2_.sendNames.push(sToController);
  30.       }
  31.       _loc2_.setDomainName(domainName);
  32.       if(_loc3_.g_NetDebugLocalConnection == undefined)
  33.       {
  34.          _loc3_.g_NetDebugLocalConnection = new LocalConnection();
  35.          _loc3_.g_NetDebugLocalConnection.allowDomain = function()
  36.          {
  37.             return true;
  38.          };
  39.       }
  40.       if(receiver != null)
  41.       {
  42.          _loc3_.g_NetDebugLocalConnection.m_Receiver = receiver;
  43.          _loc3_.g_NetDebugLocalConnection.onData = function(dataobj)
  44.          {
  45.             _global.g_NetDebugLocalConnection.m_Receiver.onReceive(dataobj);
  46.          };
  47.          _loc3_.g_NetDebugLocalConnection.onCommand = function(commandobj)
  48.          {
  49.             _global.g_NetDebugLocalConnection.m_Receiver.onReceiveCommand(commandobj);
  50.          };
  51.          if(!_loc3_.g_NetDebugLocalConnection.connect(connectname))
  52.          {
  53.             var connected = false;
  54.             _loc1_ = 0;
  55.             while(_loc1_ < _loc2_.maxConnections)
  56.             {
  57.                if(_loc3_.g_NetDebugLocalConnection.connect(connectname + _loc1_))
  58.                {
  59.                   connected = true;
  60.                   break;
  61.                }
  62.                _loc1_ = _loc1_ + 1;
  63.             }
  64.             if(!connected)
  65.             {
  66.                if(isController)
  67.                {
  68.                   receiver.onReceiveError(new mx.remoting.debug.events.NetDebugDuplicateNCDError());
  69.                }
  70.             }
  71.          }
  72.       }
  73.    }
  74.    function setDomainName(domainName)
  75.    {
  76.       var _loc1_ = domainName;
  77.       if(_loc1_ != null && _loc1_ != "")
  78.       {
  79.          this.sendPrefix = _loc1_ + ":";
  80.       }
  81.       else
  82.       {
  83.          this.sendPrefix = "";
  84.       }
  85.    }
  86.    function send(dataobj)
  87.    {
  88.       return this.sendRaw("onData",dataobj);
  89.    }
  90.    function sendCommand(commandObj)
  91.    {
  92.       return this.sendRaw("onCommand",commandObj);
  93.    }
  94.    function sendRaw(functionName, obj)
  95.    {
  96.       var _loc3_ = this;
  97.       var _loc2_ = true;
  98.       var snlen = _loc3_.sendNames.length;
  99.       var _loc1_ = 0;
  100.       while(_loc1_ < snlen)
  101.       {
  102.          _loc2_ = Boolean(_loc2_ & _global.g_NetDebugLocalConnection.send(_loc3_.sendPrefix + _loc3_.sendNames[_loc1_],functionName,obj));
  103.          _loc1_ = _loc1_ + 1;
  104.       }
  105.       return _loc2_;
  106.    }
  107. }
  108.