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

  1. package mx.messaging.messages
  2. {
  3.    import flash.utils.IDataInput;
  4.    import flash.utils.IDataOutput;
  5.    
  6.    public class CommandMessage extends AsyncMessage
  7.    {
  8.       public static const SUBSCRIBE_OPERATION:uint = 0;
  9.       
  10.       public static const UNSUBSCRIBE_OPERATION:uint = 1;
  11.       
  12.       public static const POLL_OPERATION:uint = 2;
  13.       
  14.       public static const CLIENT_SYNC_OPERATION:uint = 4;
  15.       
  16.       public static const CLIENT_PING_OPERATION:uint = 5;
  17.       
  18.       public static const CLUSTER_REQUEST_OPERATION:uint = 7;
  19.       
  20.       public static const LOGIN_OPERATION:uint = 8;
  21.       
  22.       public static const LOGOUT_OPERATION:uint = 9;
  23.       
  24.       public static const MESSAGING_VERSION:String = "DSMessagingVersion";
  25.       
  26.       public static const SUBSCRIPTION_INVALIDATE_OPERATION:uint = 10;
  27.       
  28.       public static const MULTI_SUBSCRIBE_OPERATION:uint = 11;
  29.       
  30.       public static const DISCONNECT_OPERATION:uint = 12;
  31.       
  32.       public static const TRIGGER_CONNECT_OPERATION:uint = 13;
  33.       
  34.       public static const UNKNOWN_OPERATION:uint = 10000;
  35.       
  36.       public static const AUTHENTICATION_MESSAGE_REF_TYPE:String = "flex.messaging.messages.AuthenticationMessage";
  37.       
  38.       public static const SELECTOR_HEADER:String = "DSSelector";
  39.       
  40.       public static const PRESERVE_DURABLE_HEADER:String = "DSPreserveDurable";
  41.       
  42.       public static const NEEDS_CONFIG_HEADER:String = "DSNeedsConfig";
  43.       
  44.       public static const ADD_SUBSCRIPTIONS:String = "DSAddSub";
  45.       
  46.       public static const REMOVE_SUBSCRIPTIONS:String = "DSRemSub";
  47.       
  48.       public static const SUBTOPIC_SEPARATOR:String = "_;_";
  49.       
  50.       public static const POLL_WAIT_HEADER:String = "DSPollWait";
  51.       
  52.       public static const NO_OP_POLL_HEADER:String = "DSNoOpPoll";
  53.       
  54.       public static const CREDENTIALS_CHARSET_HEADER:String = "DSCredentialsCharset";
  55.       
  56.       public static const MAX_FREQUENCY_HEADER:String = "DSMaxFrequency";
  57.       
  58.       public static const HEARTBEAT_HEADER:String = "DS<3";
  59.       
  60.       private static const OPERATION_FLAG:uint = 1;
  61.       
  62.       private static var operationTexts:Object = null;
  63.       
  64.       public var operation:uint;
  65.       
  66.       public function CommandMessage()
  67.       {
  68.          super();
  69.          operation = UNKNOWN_OPERATION;
  70.       }
  71.       
  72.       public static function getOperationAsString(param1:uint) : String
  73.       {
  74.          if(operationTexts == null)
  75.          {
  76.             operationTexts = {};
  77.             operationTexts[SUBSCRIBE_OPERATION] = "subscribe";
  78.             operationTexts[UNSUBSCRIBE_OPERATION] = "unsubscribe";
  79.             operationTexts[POLL_OPERATION] = "poll";
  80.             operationTexts[CLIENT_SYNC_OPERATION] = "client sync";
  81.             operationTexts[CLIENT_PING_OPERATION] = "client ping";
  82.             operationTexts[CLUSTER_REQUEST_OPERATION] = "cluster request";
  83.             operationTexts[LOGIN_OPERATION] = "login";
  84.             operationTexts[LOGOUT_OPERATION] = "logout";
  85.             operationTexts[SUBSCRIPTION_INVALIDATE_OPERATION] = "subscription invalidate";
  86.             operationTexts[MULTI_SUBSCRIBE_OPERATION] = "multi-subscribe";
  87.             operationTexts[DISCONNECT_OPERATION] = "disconnect";
  88.             operationTexts[TRIGGER_CONNECT_OPERATION] = "trigger connect";
  89.             operationTexts[UNKNOWN_OPERATION] = "unknown";
  90.          }
  91.          var _loc2_:* = operationTexts[param1];
  92.          return _loc2_ == undefined ? param1.toString() : String(_loc2_);
  93.       }
  94.       
  95.       override public function readExternal(param1:IDataInput) : void
  96.       {
  97.          var _loc4_:uint = 0;
  98.          var _loc5_:uint = 0;
  99.          var _loc6_:uint = 0;
  100.          super.readExternal(param1);
  101.          var _loc2_:Array = readFlags(param1);
  102.          var _loc3_:uint = 0;
  103.          while(_loc3_ < _loc2_.length)
  104.          {
  105.             _loc4_ = _loc2_[_loc3_] as uint;
  106.             _loc5_ = 0;
  107.             if(_loc3_ == 0)
  108.             {
  109.                if((_loc4_ & OPERATION_FLAG) != 0)
  110.                {
  111.                   operation = param1.readObject() as uint;
  112.                }
  113.                _loc5_ = 1;
  114.             }
  115.             if(_loc4_ >> _loc5_ != 0)
  116.             {
  117.                _loc6_ = _loc5_;
  118.                while(_loc6_ < 6)
  119.                {
  120.                   if((_loc4_ >> _loc6_ & 1) != 0)
  121.                   {
  122.                      param1.readObject();
  123.                   }
  124.                   _loc6_++;
  125.                }
  126.             }
  127.             _loc3_++;
  128.          }
  129.       }
  130.       
  131.       override protected function addDebugAttributes(param1:Object) : void
  132.       {
  133.          super.addDebugAttributes(param1);
  134.          param1["operation"] = getOperationAsString(operation);
  135.       }
  136.       
  137.       override public function writeExternal(param1:IDataOutput) : void
  138.       {
  139.          super.writeExternal(param1);
  140.          var _loc2_:uint = 0;
  141.          if(operation != 0)
  142.          {
  143.             _loc2_ |= OPERATION_FLAG;
  144.          }
  145.          param1.writeByte(_loc2_);
  146.          if(operation != 0)
  147.          {
  148.             param1.writeObject(operation);
  149.          }
  150.       }
  151.       
  152.       override public function toString() : String
  153.       {
  154.          return getDebugString();
  155.       }
  156.       
  157.       override public function getSmallMessage() : IMessage
  158.       {
  159.          if(operation == POLL_OPERATION)
  160.          {
  161.             return new CommandMessageExt(this);
  162.          }
  163.          return null;
  164.       }
  165.    }
  166. }
  167.  
  168.