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

  1. package mx.messaging.messages
  2. {
  3.    import flash.utils.ByteArray;
  4.    import flash.utils.IDataInput;
  5.    import flash.utils.IDataOutput;
  6.    import mx.utils.RPCUIDUtil;
  7.    
  8.    public class AsyncMessage extends AbstractMessage implements ISmallMessage
  9.    {
  10.       public static const SUBTOPIC_HEADER:String = "DSSubtopic";
  11.       
  12.       private static const CORRELATION_ID_FLAG:uint = 1;
  13.       
  14.       private static const CORRELATION_ID_BYTES_FLAG:uint = 2;
  15.       
  16.       private var _correlationId:String;
  17.       
  18.       private var correlationIdBytes:ByteArray;
  19.       
  20.       public function AsyncMessage(param1:Object = null, param2:Object = null)
  21.       {
  22.          super();
  23.          correlationId = "";
  24.          if(param1 != null)
  25.          {
  26.             this.body = param1;
  27.          }
  28.          if(param2 != null)
  29.          {
  30.             this.headers = param2;
  31.          }
  32.       }
  33.       
  34.       override protected function addDebugAttributes(param1:Object) : void
  35.       {
  36.          super.addDebugAttributes(param1);
  37.          param1["correlationId"] = correlationId;
  38.       }
  39.       
  40.       override public function readExternal(param1:IDataInput) : void
  41.       {
  42.          var _loc4_:uint = 0;
  43.          var _loc5_:uint = 0;
  44.          var _loc6_:uint = 0;
  45.          super.readExternal(param1);
  46.          var _loc2_:Array = readFlags(param1);
  47.          var _loc3_:uint = 0;
  48.          while(_loc3_ < _loc2_.length)
  49.          {
  50.             _loc4_ = _loc2_[_loc3_] as uint;
  51.             _loc5_ = 0;
  52.             if(_loc3_ == 0)
  53.             {
  54.                if((_loc4_ & CORRELATION_ID_FLAG) != 0)
  55.                {
  56.                   correlationId = param1.readObject() as String;
  57.                }
  58.                if((_loc4_ & CORRELATION_ID_BYTES_FLAG) != 0)
  59.                {
  60.                   correlationIdBytes = param1.readObject() as ByteArray;
  61.                   correlationId = RPCUIDUtil.fromByteArray(correlationIdBytes);
  62.                }
  63.                _loc5_ = 2;
  64.             }
  65.             if(_loc4_ >> _loc5_ != 0)
  66.             {
  67.                _loc6_ = _loc5_;
  68.                while(_loc6_ < 6)
  69.                {
  70.                   if((_loc4_ >> _loc6_ & 1) != 0)
  71.                   {
  72.                      param1.readObject();
  73.                   }
  74.                   _loc6_++;
  75.                }
  76.             }
  77.             _loc3_++;
  78.          }
  79.       }
  80.       
  81.       public function getSmallMessage() : IMessage
  82.       {
  83.          var _loc1_:Object = this;
  84.          if(_loc1_.constructor == AsyncMessage)
  85.          {
  86.             return new AsyncMessageExt(this);
  87.          }
  88.          return null;
  89.       }
  90.       
  91.       override public function writeExternal(param1:IDataOutput) : void
  92.       {
  93.          super.writeExternal(param1);
  94.          if(correlationIdBytes == null)
  95.          {
  96.             correlationIdBytes = RPCUIDUtil.toByteArray(_correlationId);
  97.          }
  98.          var _loc2_:uint = 0;
  99.          if(correlationId != null && correlationIdBytes == null)
  100.          {
  101.             _loc2_ |= CORRELATION_ID_FLAG;
  102.          }
  103.          if(correlationIdBytes != null)
  104.          {
  105.             _loc2_ |= CORRELATION_ID_BYTES_FLAG;
  106.          }
  107.          param1.writeByte(_loc2_);
  108.          if(correlationId != null && correlationIdBytes == null)
  109.          {
  110.             param1.writeObject(correlationId);
  111.          }
  112.          if(correlationIdBytes != null)
  113.          {
  114.             param1.writeObject(correlationIdBytes);
  115.          }
  116.       }
  117.       
  118.       public function set correlationId(param1:String) : void
  119.       {
  120.          _correlationId = param1;
  121.          correlationIdBytes = null;
  122.       }
  123.       
  124.       public function get correlationId() : String
  125.       {
  126.          return _correlationId;
  127.       }
  128.    }
  129. }
  130.  
  131.