home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Darbas / kidoz_v1.air / kidoz.swf / scripts / mx / messaging / messages / CommandMessage.as < prev    next >
Encoding:
Text File  |  2009-05-06  |  5.3 KB  |  164 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.       private static const OPERATION_FLAG:uint = 1;
  57.       
  58.       private static var operationTexts:Object = null;
  59.       
  60.       public var operation:uint;
  61.       
  62.       public function CommandMessage()
  63.       {
  64.          super();
  65.          operation = UNKNOWN_OPERATION;
  66.       }
  67.       
  68.       public static function getOperationAsString(param1:uint) : String
  69.       {
  70.          if(operationTexts == null)
  71.          {
  72.             operationTexts = {};
  73.             operationTexts[SUBSCRIBE_OPERATION] = "subscribe";
  74.             operationTexts[UNSUBSCRIBE_OPERATION] = "unsubscribe";
  75.             operationTexts[POLL_OPERATION] = "poll";
  76.             operationTexts[CLIENT_SYNC_OPERATION] = "client sync";
  77.             operationTexts[CLIENT_PING_OPERATION] = "client ping";
  78.             operationTexts[CLUSTER_REQUEST_OPERATION] = "cluster request";
  79.             operationTexts[LOGIN_OPERATION] = "login";
  80.             operationTexts[LOGOUT_OPERATION] = "logout";
  81.             operationTexts[SUBSCRIPTION_INVALIDATE_OPERATION] = "subscription invalidate";
  82.             operationTexts[MULTI_SUBSCRIBE_OPERATION] = "multi-subscribe";
  83.             operationTexts[DISCONNECT_OPERATION] = "disconnect";
  84.             operationTexts[TRIGGER_CONNECT_OPERATION] = "trigger connect";
  85.             operationTexts[UNKNOWN_OPERATION] = "unknown";
  86.          }
  87.          var _loc2_:* = operationTexts[param1];
  88.          return _loc2_ == undefined ? param1.toString() : String(_loc2_);
  89.       }
  90.       
  91.       override public function readExternal(param1:IDataInput) : void
  92.       {
  93.          var _loc4_:uint = 0;
  94.          var _loc5_:uint = 0;
  95.          var _loc6_:uint = 0;
  96.          super.readExternal(param1);
  97.          var _loc2_:Array = readFlags(param1);
  98.          var _loc3_:uint = 0;
  99.          while(_loc3_ < _loc2_.length)
  100.          {
  101.             _loc4_ = _loc2_[_loc3_] as uint;
  102.             _loc5_ = 0;
  103.             if(_loc3_ == 0)
  104.             {
  105.                if((_loc4_ & OPERATION_FLAG) != 0)
  106.                {
  107.                   operation = param1.readObject() as uint;
  108.                }
  109.                _loc5_ = 1;
  110.             }
  111.             if(_loc4_ >> _loc5_ != 0)
  112.             {
  113.                _loc6_ = _loc5_;
  114.                while(_loc6_ < 6)
  115.                {
  116.                   if((_loc4_ >> _loc6_ & 1) != 0)
  117.                   {
  118.                      param1.readObject();
  119.                   }
  120.                   _loc6_++;
  121.                }
  122.             }
  123.             _loc3_++;
  124.          }
  125.       }
  126.       
  127.       override protected function addDebugAttributes(param1:Object) : void
  128.       {
  129.          super.addDebugAttributes(param1);
  130.          param1["operation"] = getOperationAsString(operation);
  131.       }
  132.       
  133.       override public function writeExternal(param1:IDataOutput) : void
  134.       {
  135.          super.writeExternal(param1);
  136.          var _loc2_:uint = 0;
  137.          if(operation != 0)
  138.          {
  139.             _loc2_ |= OPERATION_FLAG;
  140.          }
  141.          param1.writeByte(_loc2_);
  142.          if(operation != 0)
  143.          {
  144.             param1.writeObject(operation);
  145.          }
  146.       }
  147.       
  148.       override public function toString() : String
  149.       {
  150.          return getDebugString();
  151.       }
  152.       
  153.       override public function getSmallMessage() : IMessage
  154.       {
  155.          if(operation == POLL_OPERATION)
  156.          {
  157.             return new CommandMessageExt(this);
  158.          }
  159.          return null;
  160.       }
  161.    }
  162. }
  163.  
  164.