home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / mx / messaging / Consumer.as < prev    next >
Encoding:
Text File  |  2010-06-23  |  2.3 KB  |  90 lines

  1. package mx.messaging
  2. {
  3.    import mx.core.mx_internal;
  4.    import mx.events.PropertyChangeEvent;
  5.    import mx.messaging.messages.AsyncMessage;
  6.    import mx.messaging.messages.CommandMessage;
  7.    import mx.messaging.messages.IMessage;
  8.    
  9.    use namespace mx_internal;
  10.    
  11.    public class Consumer extends AbstractConsumer
  12.    {
  13.       private var _selector:String = "";
  14.       
  15.       private var _subtopic:String = "";
  16.       
  17.       public function Consumer(param1:String = "flex.messaging.messages.AsyncMessage")
  18.       {
  19.          super();
  20.       }
  21.       
  22.       public function set subtopic(param1:String) : void
  23.       {
  24.          var _loc2_:Boolean = false;
  25.          if(subtopic != param1)
  26.          {
  27.             _loc2_ = false;
  28.             if(subscribed)
  29.             {
  30.                unsubscribe();
  31.                _loc2_ = true;
  32.             }
  33.             _subtopic = param1;
  34.             if(_loc2_)
  35.             {
  36.                subscribe();
  37.             }
  38.          }
  39.       }
  40.       
  41.       override protected function internalSend(param1:IMessage, param2:Boolean = true) : void
  42.       {
  43.          if(subtopic.length > 0)
  44.          {
  45.             param1.headers[AsyncMessage.SUBTOPIC_HEADER] = subtopic;
  46.          }
  47.          if(_selector.length > 0)
  48.          {
  49.             param1.headers[CommandMessage.SELECTOR_HEADER] = _selector;
  50.          }
  51.          super.internalSend(param1,param2);
  52.       }
  53.       
  54.       public function set selector(param1:String) : void
  55.       {
  56.          var _loc2_:PropertyChangeEvent = null;
  57.          var _loc3_:Boolean = false;
  58.          if(_selector !== param1)
  59.          {
  60.             _loc2_ = PropertyChangeEvent.createUpdateEvent(this,"selector",_selector,param1);
  61.             _loc3_ = false;
  62.             if(subscribed)
  63.             {
  64.                unsubscribe();
  65.                _loc3_ = true;
  66.             }
  67.             _selector = param1;
  68.             if(_loc3_)
  69.             {
  70.                subscribe(clientId);
  71.             }
  72.             dispatchEvent(_loc2_);
  73.          }
  74.       }
  75.       
  76.       [Bindable(event="propertyChange")]
  77.       public function get subtopic() : String
  78.       {
  79.          return _subtopic;
  80.       }
  81.       
  82.       [Bindable(event="propertyChange")]
  83.       public function get selector() : String
  84.       {
  85.          return _selector;
  86.       }
  87.    }
  88. }
  89.  
  90.