home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Darbas / kidoz_v1.air / kidoz.swf / scripts / mx / rpc / AbstractService.as < prev    next >
Encoding:
Text File  |  2009-05-06  |  6.6 KB  |  223 lines

  1. package mx.rpc
  2. {
  3.    import flash.events.Event;
  4.    import flash.events.EventDispatcher;
  5.    import flash.events.IEventDispatcher;
  6.    import flash.utils.Proxy;
  7.    import flash.utils.flash_proxy;
  8.    import mx.core.mx_internal;
  9.    import mx.messaging.ChannelSet;
  10.    import mx.resources.IResourceManager;
  11.    import mx.resources.ResourceManager;
  12.    import mx.rpc.events.AbstractEvent;
  13.    
  14.    use namespace mx_internal;
  15.    use namespace flash_proxy;
  16.    
  17.    [Bindable(event="operationsChange")]
  18.    public dynamic class AbstractService extends Proxy implements IEventDispatcher
  19.    {
  20.       mx_internal var asyncRequest:AsyncRequest;
  21.       
  22.       mx_internal var _operations:Object;
  23.       
  24.       private var nextNameArray:Array;
  25.       
  26.       private var eventDispatcher:EventDispatcher;
  27.       
  28.       mx_internal var _availableChannelIds:Array;
  29.       
  30.       private var resourceManager:IResourceManager = ResourceManager.getInstance();
  31.       
  32.       public function AbstractService(param1:String = null)
  33.       {
  34.          super();
  35.          eventDispatcher = new EventDispatcher(this);
  36.          mx_internal::asyncRequest = new AsyncRequest();
  37.          if(param1)
  38.          {
  39.             this.destination = param1;
  40.          }
  41.          mx_internal::_operations = {};
  42.       }
  43.       
  44.       public function dispatchEvent(param1:Event) : Boolean
  45.       {
  46.          return eventDispatcher.dispatchEvent(param1);
  47.       }
  48.       
  49.       public function setRemoteCredentials(param1:String, param2:String, param3:String = null) : void
  50.       {
  51.          mx_internal::asyncRequest.setRemoteCredentials(param1,param2,param3);
  52.       }
  53.       
  54.       public function set channelSet(param1:ChannelSet) : void
  55.       {
  56.          if(channelSet != param1)
  57.          {
  58.             mx_internal::asyncRequest.channelSet = param1;
  59.          }
  60.       }
  61.       
  62.       public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
  63.       {
  64.          eventDispatcher.removeEventListener(param1,param2,param3);
  65.       }
  66.       
  67.       public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
  68.       {
  69.          eventDispatcher.addEventListener(param1,param2,param3,param4,param5);
  70.       }
  71.       
  72.       public function get destination() : String
  73.       {
  74.          return mx_internal::asyncRequest.destination;
  75.       }
  76.       
  77.       mx_internal function hasTokenResponders(param1:Event) : Boolean
  78.       {
  79.          var _loc2_:AbstractEvent = null;
  80.          if(param1 is AbstractEvent)
  81.          {
  82.             _loc2_ = param1 as AbstractEvent;
  83.             if(_loc2_.token != null && _loc2_.token.hasResponder())
  84.             {
  85.                return true;
  86.             }
  87.          }
  88.          return false;
  89.       }
  90.       
  91.       public function get requestTimeout() : int
  92.       {
  93.          return mx_internal::asyncRequest.requestTimeout;
  94.       }
  95.       
  96.       override flash_proxy function callProperty(param1:*, ... rest) : *
  97.       {
  98.          return getOperation(mx_internal::getLocalName(param1)).send.apply(null,rest);
  99.       }
  100.       
  101.       public function willTrigger(param1:String) : Boolean
  102.       {
  103.          return eventDispatcher.willTrigger(param1);
  104.       }
  105.       
  106.       override flash_proxy function setProperty(param1:*, param2:*) : void
  107.       {
  108.          var _loc3_:String = resourceManager.getString("rpc","operationsNotAllowedInService",[mx_internal::getLocalName(param1)]);
  109.          throw new Error(_loc3_);
  110.       }
  111.       
  112.       public function set operations(param1:Object) : void
  113.       {
  114.          var _loc2_:AbstractOperation = null;
  115.          var _loc3_:String = null;
  116.          for(_loc3_ in param1)
  117.          {
  118.             _loc2_ = AbstractOperation(param1[_loc3_]);
  119.             _loc2_.mx_internal::setService(this);
  120.             if(!_loc2_.name)
  121.             {
  122.                _loc2_.name = _loc3_;
  123.             }
  124.             _loc2_.mx_internal::asyncRequest = mx_internal::asyncRequest;
  125.          }
  126.          mx_internal::_operations = param1;
  127.       }
  128.       
  129.       public function logout() : void
  130.       {
  131.          mx_internal::asyncRequest.logout();
  132.       }
  133.       
  134.       override flash_proxy function getProperty(param1:*) : *
  135.       {
  136.          return getOperation(mx_internal::getLocalName(param1));
  137.       }
  138.       
  139.       public function set destination(param1:String) : void
  140.       {
  141.          mx_internal::asyncRequest.destination = param1;
  142.       }
  143.       
  144.       override flash_proxy function nextName(param1:int) : String
  145.       {
  146.          return nextNameArray[param1 - 1];
  147.       }
  148.       
  149.       public function get channelSet() : ChannelSet
  150.       {
  151.          return mx_internal::asyncRequest.channelSet;
  152.       }
  153.       
  154.       override flash_proxy function nextValue(param1:int) : *
  155.       {
  156.          return mx_internal::_operations[nextNameArray[param1 - 1]];
  157.       }
  158.       
  159.       override flash_proxy function nextNameIndex(param1:int) : int
  160.       {
  161.          var _loc2_:String = null;
  162.          if(param1 == 0)
  163.          {
  164.             nextNameArray = [];
  165.             for(_loc2_ in mx_internal::_operations)
  166.             {
  167.                nextNameArray.push(_loc2_);
  168.             }
  169.          }
  170.          return param1 < nextNameArray.length ? param1 + 1 : 0;
  171.       }
  172.       
  173.       public function set requestTimeout(param1:int) : void
  174.       {
  175.          if(requestTimeout != param1)
  176.          {
  177.             mx_internal::asyncRequest.requestTimeout = param1;
  178.          }
  179.       }
  180.       
  181.       mx_internal function getLocalName(param1:Object) : String
  182.       {
  183.          if(param1 is QName)
  184.          {
  185.             return QName(param1).localName;
  186.          }
  187.          return String(param1);
  188.       }
  189.       
  190.       public function valueOf() : Object
  191.       {
  192.          return this;
  193.       }
  194.       
  195.       public function disconnect() : void
  196.       {
  197.          mx_internal::asyncRequest.disconnect();
  198.       }
  199.       
  200.       public function get operations() : Object
  201.       {
  202.          return mx_internal::_operations;
  203.       }
  204.       
  205.       public function getOperation(param1:String) : AbstractOperation
  206.       {
  207.          var _loc2_:Object = mx_internal::_operations[param1];
  208.          return _loc2_ is AbstractOperation ? AbstractOperation(_loc2_) : null;
  209.       }
  210.       
  211.       public function setCredentials(param1:String, param2:String, param3:String = null) : void
  212.       {
  213.          mx_internal::asyncRequest.setCredentials(param1,param2,param3);
  214.       }
  215.       
  216.       public function hasEventListener(param1:String) : Boolean
  217.       {
  218.          return eventDispatcher.hasEventListener(param1);
  219.       }
  220.    }
  221. }
  222.  
  223.