You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2018/08/08 22:12:07 UTC

[royale-asjs] branch feature/MXRoyale updated: Support for RoyaleClientID (like FlexClientId) in headers to make BlazeDS recognize the current client and make royale work with BlazeDS FlexSession and credentials. Some additional work is done here with readExternal and writeExternal methods, those compile, but are not tested, and sure needs more work, but at least compile. The same for IDataInput and IDataOutput that should replace flash.utils. counterparts

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch feature/MXRoyale
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/feature/MXRoyale by this push:
     new aa7172b  Support for RoyaleClientID (like FlexClientId) in headers to make BlazeDS recognize the current client and make royale work with BlazeDS FlexSession and credentials. Some additional work is done here with readExternal and writeExternal methods, those compile, but are not tested, and sure needs more work, but at least compile. The same for IDataInput and IDataOutput that should replace flash.utils. counterparts
aa7172b is described below

commit aa7172b7dfa42d1fd2e453672f7e832bd729037b
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Mon May 28 03:10:55 2018 +0200

    Support for RoyaleClientID (like FlexClientId) in headers to make BlazeDS recognize the current client and make royale work with BlazeDS FlexSession and credentials.
    Some additional work is done here with readExternal and writeExternal methods, those compile, but are not tested, and sure needs more work, but at least compile.
    The same for IDataInput and IDataOutput that should replace flash.utils. counterparts
    
    # Conflicts:
    #	examples/royale/RemoteObjectAMFTest/src/main/royale/App.mxml
    #	frameworks/projects/Network/src/main/royale/org/apache/royale/net/RemoteObject.as
---
 .../Network/src/main/royale/NetworkClasses.as      |  13 +-
 .../royale/org/apache/royale/net/RemoteObject.as   | 227 +++++++++---------
 .../org/apache/royale/net/remoting/Operation.as    |  44 +++-
 .../net/remoting/messages/AbstractMessage.as       |  45 ++--
 .../net/remoting/messages/AcknowledgeMessageExt.as |  72 ++++++
 .../royale/net/remoting/messages/AsyncMessage.as   |  38 +--
 .../royale/net/remoting/messages/RoyaleClient.as   | 200 ++++++++++++++++
 .../org/apache/royale/net/utils/IDataInput.as      |  34 +++
 .../org/apache/royale/net/utils/IDataOutput.as     |  35 +++
 .../org/apache/royale/net/utils/RPCUIDUtil.as      | 259 +++++++++++++++++++++
 10 files changed, 794 insertions(+), 173 deletions(-)

diff --git a/frameworks/projects/Network/src/main/royale/NetworkClasses.as b/frameworks/projects/Network/src/main/royale/NetworkClasses.as
index afff91f..8326aee 100644
--- a/frameworks/projects/Network/src/main/royale/NetworkClasses.as
+++ b/frameworks/projects/Network/src/main/royale/NetworkClasses.as
@@ -33,10 +33,21 @@ package
         import org.apache.royale.net.events.ResultEvent; ResultEvent;
         import org.apache.royale.net.events.FaultEvent; FaultEvent;
         
+        import org.apache.royale.net.remoting.messages.AcknowledgeMessageExt;
+        import org.apache.royale.net.remoting.messages.CommandMessage;
         import org.apache.royale.net.remoting.messages.AsyncMessage; AsyncMessage;
-        import org.apache.royale.net.remoting.messages.CommandMessage; CommandMessage;
         import org.apache.royale.net.remoting.messages.RemotingMessage; RemotingMessage;
         import org.apache.royale.net.remoting.messages.AcknowledgeMessage; AcknowledgeMessage;
+
+        import org.apache.royale.net.remoting.messages.RoyaleClient; RoyaleClient;
+        import org.apache.royale.net.utils.RPCUIDUtil; RPCUIDUtil;
+        
+        
+        import org.apache.royale.reflection.registerClassAlias;
+        //RpcClassAliasInitializer
+        registerClassAlias("org.apache.royale.net.remoting.messages.CommandMessage", CommandMessage);
+        registerClassAlias("DSK", AcknowledgeMessageExt);
+
     }
 }
 
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/RemoteObject.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/RemoteObject.as
index b44703d..95d8b09 100755
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/RemoteObject.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/RemoteObject.as
@@ -1,110 +1,119 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.royale.net
-{
-    
-    import org.apache.royale.core.IBead;
-    import org.apache.royale.core.IStrand;
-    import org.apache.royale.events.EventDispatcher;
-    import org.apache.royale.net.events.FaultEvent;
-    import org.apache.royale.net.events.ResultEvent;
-    import org.apache.royale.net.remoting.Operation;
-    import org.apache.royale.net.remoting.amf.AMFNetConnection;
-    import org.apache.royale.reflection.getClassByAlias;
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.net
+{
+    
+    import org.apache.royale.core.IBead;
+    import org.apache.royale.core.IStrand;
+    import org.apache.royale.events.EventDispatcher;
+    import org.apache.royale.net.events.FaultEvent;
+    import org.apache.royale.net.events.ResultEvent;
+    import org.apache.royale.net.remoting.Operation;
+    import org.apache.royale.net.remoting.amf.AMFNetConnection;
+    import org.apache.royale.reflection.getClassByAlias;
     import org.apache.royale.reflection.registerClassAlias;
-
-	[Event(name="result", type="org.apache.royale.net.events.ResultEvent")]
-	[Event(name="fault", type="org.apache.royale.net.events.FaultEvent")]
-	public class RemoteObject extends EventDispatcher implements IBead
-	{
-		private var _endPoint:String;
-		private var _destination:String;
-		private var _source:String;
-        
-        /**
-         *  @private
-         *  The connection to the server 
-         * 
-         *  @royalesuppresspublicvarwarning
-         */
-        public var nc:AMFNetConnection = new AMFNetConnection();
-		
-		/** 
-		 * 
-		 * <inject_html>
-		 * <script src="https://rawgit.com/emilkm/amfjs/master/amf.js"></script>
-		 * </inject_html>
-		 */ 
-		public function RemoteObject()
-		{
-		}
-		
-        private var _strand:IStrand;
-        
-        public function set strand(value:IStrand):void
-        {
-            _strand = value;	
-        }
-        
-		public function set endPoint(value:String):void
-		{
-			_endPoint = value;	
-		}
-		public function get endPoint():String
-		{
-			return _endPoint;	
-		}
-		
-		public function set destination(value:String):void
-		{
-			_destination = value;	
-		}
-		public function get destination():String
-		{
-			return _destination;	
-		}
-		
-		public function set source(value:String):void
-		{
-			_source = value;	
-		}
-		public function get source():String
-		{
-			return _source;	
-		}
-		
-		public function send(operation:String, params:Array):void
-		{
-            nc.connect(endPoint);
-            
-            var op:Operation = new Operation(operation, this, params);
-            op.send();
-		}
-		
-		public function resultHandler(param:Object):void
-		{
-    		dispatchEvent(new ResultEvent(ResultEvent.RESULT, param.body));
-		}
-		
-		public function faultHandler(param:Object):void
-		{
-			dispatchEvent(new FaultEvent(FaultEvent.FAULT, param));
-		}		
-	}
-}
+	import org.apache.royale.net.remoting.messages.AcknowledgeMessage;
+	import org.apache.royale.net.remoting.messages.RoyaleClient;
+
+	[Event(name="result", type="org.apache.royale.net.events.ResultEvent")]
+	[Event(name="fault", type="org.apache.royale.net.events.FaultEvent")]
+	public class RemoteObject extends EventDispatcher implements IBead
+	{
+		private var _endPoint:String;
+		private var _destination:String;
+		private var _source:String;
+        
+        /**
+         *  @private
+         *  The connection to the server 
+         * 
+         *  @royalesuppresspublicvarwarning
+         */
+        public var nc:AMFNetConnection = new AMFNetConnection();
+		
+		/** 
+		 * 
+		 */ 
+		public function RemoteObject()
+		{
+		}
+		
+        private var _strand:IStrand;
+        
+        public function set strand(value:IStrand):void
+        {
+            _strand = value;	
+        }
+        
+		public function set endPoint(value:String):void
+		{
+			_endPoint = value;	
+		}
+		public function get endPoint():String
+		{
+			return _endPoint;	
+		}
+		
+		public function set destination(value:String):void
+		{
+			_destination = value;	
+		}
+		public function get destination():String
+		{
+			return _destination;	
+		}
+		
+		public function set source(value:String):void
+		{
+			_source = value;	
+		}
+		public function get source():String
+		{
+			return _source;	
+		}
+		
+		public function send(operation:String, params:Array):void
+		{
+            nc.connect(endPoint);
+            
+            var op:Operation = new Operation(operation, this, params);
+            op.send();
+		}
+		
+		public function resultHandler(param:Object):void
+		{
+			if (param is AcknowledgeMessage)
+			{
+				// Set the server assigned RoyaleClient Id.
+				if (RoyaleClient.getInstance().id == null && param.clientId)//msg.headers[AbstractMessage.ROYALE_CLIENT_ID_HEADER] != null)
+				{
+					RoyaleClient.getInstance().id = param.clientId;//msg.headers[AbstractMessage.ROYALE_CLIENT_ID_HEADER];
+					//trace("SET RoyaleClient.getInstance().id " + RoyaleClient.getInstance().id);
+				}
+			}
+
+    		dispatchEvent(new ResultEvent(ResultEvent.RESULT, param.body));
+		}
+		
+		public function faultHandler(param:Object):void
+		{
+			dispatchEvent(new FaultEvent(FaultEvent.FAULT, param));
+		}		
+	}
+}
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/Operation.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/Operation.as
index c6762d0..e887640 100755
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/Operation.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/Operation.as
@@ -26,9 +26,11 @@ package org.apache.royale.net.remoting
     import org.apache.royale.net.remoting.messages.RemotingMessage;
     import org.apache.royale.net.events.FaultEvent;
     import org.apache.royale.net.events.ResultEvent;
-    import org.apache.royale.reflection.getClassByAlias;
-    import org.apache.royale.reflection.registerClassAlias;
-    
+    
+    import org.apache.royale.net.remoting.messages.AbstractMessage;
+    import org.apache.royale.net.remoting.messages.IMessage;
+    import org.apache.royale.net.remoting.messages.RoyaleClient;
+
 
 	public class Operation extends EventDispatcher
 	{
@@ -46,8 +48,18 @@ package org.apache.royale.net.remoting
 		public function send():void
 		{
             var connectMessage:CommandMessage = new CommandMessage();
+
+            var id:String = RoyaleClient.getInstance().id;
+            //connectMessage.operation = (id != null) ? CommandMessage.TRIGGER_CONNECT_OPERATION : CommandMessage.CLIENT_PING_OPERATION;
+            connectMessage.operation = CommandMessage.TRIGGER_CONNECT_OPERATION 
+            // if(connectMessage.operation == CommandMessage.CLIENT_PING_OPERATION)
+            // {
+            connectMessage.correlationId = null;
+            setRoyaleClientIdOnMessage(connectMessage);
+            connectMessage.headers[CommandMessage.MESSAGING_VERSION] = messagingVersion;
+            // } else {
             connectMessage.destination = _ro.destination;
-            connectMessage.operation = CommandMessage.TRIGGER_CONNECT_OPERATION;
+            // }
             _ro.nc.call(null, new Responder(destinationResultHandler, destinationFaultHandler), connectMessage);
 		}
 		
@@ -60,6 +72,7 @@ package org.apache.royale.net.remoting
                 message.body = _args;
                 message.source = _ro.source;
                 message.destination = _ro.destination;
+                setRoyaleClientIdOnMessage(message);
                 _ro.nc.call(null, new Responder(_ro.resultHandler, _ro.faultHandler), message);
             }
             COMPILE::JS
@@ -71,6 +84,9 @@ package org.apache.royale.net.remoting
                     message.body = _args;
                     message.source = _ro.source;
                     message.destination = _ro.destination;
+
+                    setRoyaleClientIdOnMessage(message);
+
                     _ro.nc.call(null, new Responder(_ro.resultHandler, _ro.faultHandler), message);
                 }
                 else
@@ -83,5 +99,25 @@ package org.apache.royale.net.remoting
             trace("destination fault handler", param);            
         }
         
+        /**
+         *  @private
+         *  Utility method used to assign the RoyaleClient Id value to outbound messages.
+         * 
+         *  @param message The message to set the RoyaleClient Id on.
+         */
+        protected function setRoyaleClientIdOnMessage(message:IMessage):void
+        {
+            var id:String = RoyaleClient.getInstance().id;
+            //trace("[*setRoyaleClientIdOnMessage] RoyaleClient.getInstance().id: " + RoyaleClient.getInstance().id);
+            message.headers[AbstractMessage.ROYALE_CLIENT_ID_HEADER] = (id != null) ? id : RoyaleClient.NULL_ROYALECLIENT_ID;
+        }
+
+        /**
+         * @private
+         * The messaging version implies which features are enabled on this client
+         * channel. Channel endpoints exchange this information through headers on
+         * the ping CommandMessage exchanged during the connection handshake.
+         */
+        protected var messagingVersion:Number = 1.0;
     }
 }
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AbstractMessage.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AbstractMessage.as
index 744c2a1..90a6736 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AbstractMessage.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AbstractMessage.as
@@ -20,24 +20,16 @@
 package org.apache.royale.net.remoting.messages
 {
 
-COMPILE::SWF
-{
-    import flash.utils.ByteArray;
-    import flash.utils.IDataInput;
-    import flash.utils.IDataOutput;
-    import flash.utils.getQualifiedClassName;
-}
-
 import org.apache.royale.utils.ObjectUtil;
 import org.apache.royale.utils.UIDUtil;
+import org.apache.royale.net.utils.IDataInput;
+import org.apache.royale.net.utils.IDataOutput;
+import org.apache.royale.utils.BinaryData;
+import org.apache.royale.net.utils.RPCUIDUtil;
 
 /*
-import mx.core.mx_internal;
 import mx.utils.RPCObjectUtil;
 import mx.utils.RPCStringUtil;
-import mx.utils.RPCUIDUtil;
-
-use namespace mx_internal;
 */
 
 /**
@@ -52,6 +44,9 @@ use namespace mx_internal;
  *  delivered and processed by the remote destination.
  *  The <code>body</code> is an object and is the payload for a message.
  *  </p>
+ * 
+ *  Note: readExternal and writeExternal methods compile but are not tested and maybe not work
+ *  but is an initial work
  *  
  *  @langversion 3.0
  *  @playerversion Flash 9
@@ -94,7 +89,7 @@ public class AbstractMessage implements IMessage
 	public static const ENDPOINT_HEADER:String = "DSEndpoint";
 
 	/**
-	 *  This header is used to transport the global FlexClient Id value in outbound 
+	 *  This header is used to transport the global RoyaleClient Id value in outbound
 	 *  messages once it has been assigned by the server.
 	 *  
 	 *  @langversion 3.0
@@ -103,7 +98,7 @@ public class AbstractMessage implements IMessage
 	 *  @productversion BlazeDS 4
 	 *  @productversion LCDS 3 
 	 */
-	public static const FLEX_CLIENT_ID_HEADER:String = "DSId";
+	public static const ROYALE_CLIENT_ID_HEADER:String = "DSId";
 
     /**
      *  Messages sent by a MessageAgent can have a priority header with a 0-9
@@ -178,7 +173,6 @@ public class AbstractMessage implements IMessage
     // 
     //--------------------------------------------------------------------------
 
-    /*
     private static const HAS_NEXT_FLAG:uint = 128;
     private static const BODY_FLAG:uint = 1;
     private static const CLIENT_ID_FLAG:uint = 2;
@@ -189,7 +183,6 @@ public class AbstractMessage implements IMessage
     private static const TIME_TO_LIVE_FLAG:uint = 64;
     private static const CLIENT_ID_BYTES_FLAG:uint = 1;
     private static const MESSAGE_ID_BYTES_FLAG:uint = 2;
-    */
 
     //--------------------------------------------------------------------------
     //
@@ -262,8 +255,7 @@ public class AbstractMessage implements IMessage
 	/**
 	 * @private
 	 */
-    COMPILE::SWF
-    private var clientIdBytes:ByteArray;
+    private var clientIdBytes:BinaryData;
 
     /**
      *  The clientId indicates which MessageAgent sent the message.
@@ -373,8 +365,7 @@ public class AbstractMessage implements IMessage
     /**
      * @private
      */
-    COMPILE::SWF
-    private var messageIdBytes:ByteArray;
+    private var messageIdBytes:BinaryData;
 
     /**
      *  The unique id for the message.
@@ -496,7 +487,6 @@ public class AbstractMessage implements IMessage
      * functionality by implementing IExternalizable.readExternal(IDataInput) to
      * deserialize the properties for this abstract base class.
      */
-    /* LATER
     public function readExternal(input:IDataInput):void
     {
         var flagsArray:Array = readFlags(input);
@@ -537,13 +527,13 @@ public class AbstractMessage implements IMessage
             {
                 if ((flags & CLIENT_ID_BYTES_FLAG) != 0)
                 {
-                    clientIdBytes = input.readObject() as ByteArray;
+                    clientIdBytes = input.readObject() as BinaryData;
                     clientId = RPCUIDUtil.fromByteArray(clientIdBytes);
                 }
         
                 if ((flags & MESSAGE_ID_BYTES_FLAG) != 0)
                 {
-                    messageIdBytes = input.readObject() as ByteArray;
+                    messageIdBytes = input.readObject() as BinaryData;
                     messageId = RPCUIDUtil.fromByteArray(messageIdBytes);
                 }
 
@@ -564,7 +554,6 @@ public class AbstractMessage implements IMessage
             }
         }
     }
-    */
 
     /**
      *  Returns a string representation of the message.
@@ -591,7 +580,6 @@ public class AbstractMessage implements IMessage
      * functionality by implementing IExternalizable.writeExternal(IDataOutput)
      * to efficiently serialize the properties for this abstract base class.
      */
-    /*
     public function writeExternal(output:IDataOutput):void
     {
         var flags:uint = 0;
@@ -671,7 +659,6 @@ public class AbstractMessage implements IMessage
         if (messageIdBytes != null)
             output.writeObject(messageIdBytes);
     }
-    */
 
     //--------------------------------------------------------------------------
     //
@@ -728,12 +715,10 @@ public class AbstractMessage implements IMessage
     /**
      * @private
      */
-    /*
     protected function readExternalBody(input:IDataInput):void
     {
         body = input.readObject();
     }
-    */
     
     /**
      * @private
@@ -746,7 +731,6 @@ public class AbstractMessage implements IMessage
      * @return The Array of property flags. Each flags byte is stored as a uint
      * in the Array.
      */
-    /*
     protected function readFlags(input:IDataInput):Array
     {
         var hasNextFlag:Boolean = true;
@@ -765,17 +749,14 @@ public class AbstractMessage implements IMessage
 
         return flagsArray;
     }
-    */
 
     /**
      * @private
      */
-    /*
     protected function writeExternalBody(output:IDataOutput):void
     {
         output.writeObject(body);
     }
-    */
 }
 
 }
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AcknowledgeMessageExt.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AcknowledgeMessageExt.as
new file mode 100644
index 0000000..25d54a8
--- /dev/null
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AcknowledgeMessageExt.as
@@ -0,0 +1,72 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.net.remoting.messages
+{
+    // import flash.utils.IDataOutput;
+    // import flash.utils.IExternalizable;
+    import org.apache.royale.net.utils.IDataOutput;
+
+    [RemoteClass(alias="DSK")]
+    /**
+     * @private
+     */
+    public class AcknowledgeMessageExt extends AcknowledgeMessage// implements IExternalizable
+    {
+        //--------------------------------------------------------------------------
+        //
+        // Constructor
+        // 
+        //--------------------------------------------------------------------------
+
+        public function AcknowledgeMessageExt(message:AcknowledgeMessage = null)
+        {
+            super();
+            _message = message;
+        }
+
+        override public function writeExternal(output:IDataOutput):void
+        {
+            if (_message != null)
+                _message.writeExternal(output);
+            else
+                super.writeExternal(output);
+        }
+
+        /**
+         *  The unique id for the message.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion BlazeDS 4
+         *  @productversion LCDS 3 
+         */
+        override public function get messageId():String
+        {
+            /* If we are wrapping another message, use its messageId */
+            if (_message != null)
+                return _message.messageId;
+
+            return super.messageId;
+        }
+
+        private var _message:AcknowledgeMessage;
+    }
+
+}
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AsyncMessage.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AsyncMessage.as
index 299e923..93cc1b6 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AsyncMessage.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/AsyncMessage.as
@@ -20,17 +20,17 @@
 package org.apache.royale.net.remoting.messages
 {
 
-COMPILE::SWF
-{
-import flash.utils.ByteArray;
-import flash.utils.IDataInput;
-import flash.utils.IDataOutput;
-}
+import org.apache.royale.net.utils.IDataInput;
+import org.apache.royale.net.utils.IDataOutput;
+import org.apache.royale.utils.BinaryData;
+import org.apache.royale.net.utils.RPCUIDUtil;
 
 [RemoteClass(alias="flex.messaging.messages.AsyncMessage")]
 
 /**
  *  AsyncMessage is the base class for all asynchronous messages.
+ *  Note: readExternal and writeExternal methods compile but are not tested and maybe not work
+ *  but is an initial work
  *  
  *  @langversion 3.0
  *  @playerversion Flash 9
@@ -64,10 +64,8 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
     // 
     //--------------------------------------------------------------------------
 
-    /*
     private static const CORRELATION_ID_FLAG:uint = 1;
     private static const CORRELATION_ID_BYTES_FLAG:uint = 2;
-    */
     
     //--------------------------------------------------------------------------
     //
@@ -98,7 +96,7 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
     {
         super();
 
-        //correlationId = "";
+        correlationId = "";
         if (body != null)
             this.body = body;
             
@@ -119,16 +117,12 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
     /**
      * @private
      */
-    /*
     private var _correlationId:String;
-    */
     
     /**
      * @private
      */
-    /*
-    private var correlationIdBytes:ByteArray;
-    */
+    private var correlationIdBytes:BinaryData;
     
     /**
      *  Provides access to the correlation id of the message.
@@ -144,23 +138,19 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
      *  @productversion BlazeDS 4
      *  @productversion LCDS 3 
      */
-    /*
     public function get correlationId():String
     {
         return _correlationId;
     }
-    */
     
     /**
      * @private
      */
-    /*
     public function set correlationId(value:String):void
     {
         _correlationId = value;
         correlationIdBytes = null;
     }
-    */
 
     //--------------------------------------------------------------------------
     //
@@ -171,8 +161,7 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
     /**
      * @private
      */
-    /*
-    public function getSmallMessage():IMessage
+    /*public function getSmallMessage():IMessage
     {
         // If it is a subclass, it will need to override this itself if it wants to use
         // small messages.
@@ -180,13 +169,11 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
         if (o.constructor == AsyncMessage)
             return new AsyncMessageExt(this);
         return null;
-    }
-    */
+    }*/
     
     /**
      * @private
      */
-    /*
     override public function readExternal(input:IDataInput):void
     {
         super.readExternal(input);
@@ -204,7 +191,7 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
 
                 if ((flags & CORRELATION_ID_BYTES_FLAG) != 0)
                 {
-                    correlationIdBytes = input.readObject() as ByteArray;
+                    correlationIdBytes = input.readObject() as BinaryData;
                     correlationId = RPCUIDUtil.fromByteArray(correlationIdBytes);
                 }
 
@@ -225,12 +212,10 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
             }
         }
     }
-    */
 
     /**
      * @private
      */
-    /*
     override public function writeExternal(output:IDataOutput):void
     {
         super.writeExternal(output);
@@ -254,7 +239,6 @@ public class AsyncMessage extends AbstractMessage // implements ISmallMessage
         if (correlationIdBytes != null)
             output.writeObject(correlationIdBytes);
     }
-    */
     
     /**
      *  @private
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/RoyaleClient.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/RoyaleClient.as
new file mode 100644
index 0000000..0b91d2e
--- /dev/null
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/messages/RoyaleClient.as
@@ -0,0 +1,200 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.net.remoting.messages
+{
+    import org.apache.royale.events.EventDispatcher;
+   
+    /**
+     *  Dispatched when a property of the RoyaleClient singleton changes.
+     *  Listeners must be added via RoyaleClient.getInstance().addEventListener(...).
+     * 
+     *  @eventType mx.events.PropertyChangeEvent.PROPERTY_CHANGE
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion BlazeDS 4
+     *  @productversion LCDS 3 
+     */
+    //[Event(name="propertyChange", type="mx.events.PropertyChangeEvent")]    
+        
+    /**
+     *  Singleton class that stores the global Id for this instance that is 
+     *  server assigned when the client makes its initial connection to the server.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion BlazeDS 4
+     *  @productversion LCDS 3 
+     */
+    public class RoyaleClient extends EventDispatcher
+    {
+        //--------------------------------------------------------------------------
+        //
+        //  Class constants
+        //
+        //--------------------------------------------------------------------------
+
+        /**
+         *  @private
+         *  This value is passed to the server in an initial client connect to
+         *  indicate that the client needs a server-assigned RoyaleClient Id.
+         */
+        public static const NULL_ROYALECLIENT_ID:String = "nil";
+
+        //--------------------------------------------------------------------------
+        //
+        //  Class variables
+        //
+        //--------------------------------------------------------------------------
+
+        /**
+         *  @private
+         *  The sole instance of this singleton class.
+         */
+        private static var _instance:RoyaleClient;
+        
+        //--------------------------------------------------------------------------
+        //
+        //  Class methods
+        //
+        //--------------------------------------------------------------------------
+
+        /**
+         *  Returns the sole instance of this singleton class,
+         *  creating it if it does not already exist.
+         *
+         *  @return Returns the sole instance of this singleton class,
+         *  creating it if it does not already exist.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion BlazeDS 4
+         *  @productversion LCDS 3 
+         */
+        public static function getInstance():RoyaleClient
+        {
+            if (_instance == null){
+                _instance = new RoyaleClient();
+            }
+
+            return _instance;
+        }
+
+        //--------------------------------------------------------------------------
+        //
+        //  Constructor
+        //
+        //--------------------------------------------------------------------------
+
+        /**
+         *  @private
+         *  Constructor.
+         */
+        public function RoyaleClient()
+        {
+            super();
+        }    
+        
+        //--------------------------------------------------------------------------
+        //
+        //  Properties
+        //
+        //--------------------------------------------------------------------------
+
+        //----------------------------------
+        //  id
+        //----------------------------------
+
+        /**
+         *  @private
+         *  Storage for the global RoyaleClient Id for the this instance. 
+         *  This value is server assigned and is set as part of the Channel connect process.
+         */	
+        private var _id:String = null;
+        
+        //[Bindable(event="propertyChange")]
+        /**
+         *  The global RoyaleClient Id for this this instance.
+         *  This value is server assigned and is set as part of the Channel connect process.
+         *  Once set, it will not change for the duration of the instance's lifespan.
+         *  If no Channel has connected to a server this value is null.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion BlazeDS 4
+         *  @productversion LCDS 3 
+         */
+        public function get id():String
+        {
+            return _id;
+        } 
+            
+        /**
+         *  @private
+         */
+        public function set id(value:String):void
+        {
+            if (_id != value)
+            {
+                //var event:PropertyChangeEvent = PropertyChangeEvent.createUpdateEvent(this, "id", _id, value);
+                _id = value;
+                //dispatchEvent(event);
+            }        
+        }
+        
+        //----------------------------------
+        //  waitForRoyaleClientId
+        //----------------------------------
+                
+        /**
+         *  @private
+         */
+        //private var _waitForRoyaleClientId:Boolean = false; // Initialize to false so the first Channel that checks this can attempt to connect.
+        
+        //[Bindable(event="propertyChange")]
+        /**
+         *  @private 
+         *  Guard condition that Channel instances use to coordinate their connect attempts during application startup
+         *  when a RoyaleClient Id has not yet been returned by the server.
+         *  The initial Channel connect process must be serialized.
+         *  Once a RoyaleClient Id is set further Channel connects and disconnects do not require synchronization.
+         */
+        /*private function get waitForRoyaleClientId():Boolean
+        {
+            return _waitForRoyaleClientId;
+        }*/
+        
+        /**
+         *  @private
+         */
+        /*private function set waitForRoyaleClientId(value:Boolean):void
+        {
+            if (_waitForRoyaleClientId != value)
+            {
+                //var event:PropertyChangeEvent = PropertyChangeEvent.createUpdateEvent(this, "waitForFlexClientId", _waitForRoyaleClientId, value);
+                _waitForRoyaleClientId = value;
+                //dispatchEvent(event);
+            }
+        }*/
+    }
+}
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/IDataInput.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/IDataInput.as
new file mode 100644
index 0000000..1916c00
--- /dev/null
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/IDataInput.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.net.utils
+{
+    
+    /**
+     * initial work on replacement for flash.utils.IDataInput
+     */
+    public interface IDataInput
+    {
+        function get bytesAvailable():uint;
+
+        function readUnsignedByte():uint;
+
+        function readObject():*;
+    }
+
+}
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/IDataOutput.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/IDataOutput.as
new file mode 100644
index 0000000..cb59c1a
--- /dev/null
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/IDataOutput.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.net.utils
+{
+    import org.apache.royale.net.remoting.amf.AMFBinaryData;
+
+    /**
+     * initial work on replacement for flash.utils.IDataOutput
+     */
+    public interface IDataOutput
+    {
+        function writeBytes(bytes:AMFBinaryData, offset:uint = 0, length:uint = 0):void;
+
+        function writeByte(value:int):void;
+
+        function writeObject(object:*):void;
+    }
+
+}
\ No newline at end of file
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/RPCUIDUtil.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/RPCUIDUtil.as
new file mode 100644
index 0000000..15cf2ad
--- /dev/null
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/utils/RPCUIDUtil.as
@@ -0,0 +1,259 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed under the Apache License, Version 2.0 (the "License");
+//  you may not use this file except in compliance with the License.
+//  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.net.utils
+{
+    import org.apache.royale.utils.BinaryData;
+
+    /**
+     *  The RPCUIDUtil class is a copy of UIDUtil without some functions that
+     *  cause dependency problems when RPC messages are put in a bootstrap loader.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public class RPCUIDUtil
+    {
+        //--------------------------------------------------------------------------
+        //
+        //  Class constants
+        //
+        //--------------------------------------------------------------------------
+
+        /**
+         *  @private
+         *  Char codes for 0123456789ABCDEF
+         */
+        private static const ALPHA_CHAR_CODES:Array = [48, 49, 50, 51, 52, 53, 54, 
+            55, 56, 57, 65, 66, 67, 68, 69, 70];
+
+        private static const DASH:int = 45;       // dash ascii
+        private static const UIDBuffer:BinaryData = new BinaryData();       // static ByteArray used for UID generation to save memory allocation cost
+
+        //--------------------------------------------------------------------------
+        //
+        //  Class methods
+        //
+        //--------------------------------------------------------------------------
+
+        /**
+         *  Generates a UID (unique identifier) based on ActionScript's
+         *  pseudo-random number generator and the current time.
+         *
+         *  <p>The UID has the form
+         *  <code>"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"</code>
+         *  where X is a hexadecimal digit (0-9, A-F).</p>
+         *
+         *  <p>This UID will not be truly globally unique; but it is the best
+         *  we can do without player support for UID generation.</p>
+         *
+         *  @return The newly-generated UID.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        public static function createUID():String
+        {
+            UIDBuffer.position = 0;
+
+            var i:int;
+            var j:int;
+
+            for (i = 0; i < 8; i++)
+            {
+                UIDBuffer.writeByte(ALPHA_CHAR_CODES[int(Math.random() * 16)]);
+            }
+
+            for (i = 0; i < 3; i++)
+            {
+                UIDBuffer.writeByte(DASH);
+                for (j = 0; j < 4; j++)
+                {
+                    UIDBuffer.writeByte(ALPHA_CHAR_CODES[int(Math.random() * 16)]);
+                }
+            }
+
+            UIDBuffer.writeByte(DASH);
+
+            var time:uint = new Date().getTime(); // extract last 8 digits
+            var timeString:String = time.toString(16).toUpperCase();
+            // 0xFFFFFFFF milliseconds ~= 3 days, so timeString may have between 1 and 8 digits, hence we need to pad with 0s to 8 digits
+            for (i = 8; i > timeString.length; i--)
+                UIDBuffer.writeByte(48);
+            UIDBuffer.writeUTFBytes(timeString);
+
+            for (i = 0; i < 4; i++)
+            {
+                UIDBuffer.writeByte(ALPHA_CHAR_CODES[int(Math.random() * 16)]);
+            }
+
+            return UIDBuffer.toString();
+        }
+
+        /**
+         * Converts a 128-bit UID encoded as a ByteArray to a String representation.
+         * The format matches that generated by createUID. If a suitable ByteArray
+         * is not provided, null is returned.
+         * 
+         * @param ba ByteArray 16 bytes in length representing a 128-bit UID.
+         * 
+         * @return String representation of the UID, or null if an invalid
+         * ByteArray is provided.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        public static function fromByteArray(ba:BinaryData):String
+        {
+            if (ba != null && ba.length >= 16 && ba.bytesAvailable >= 16)
+            {
+                UIDBuffer.position = 0;
+                var index:uint = 0;
+                for (var i:uint = 0; i < 16; i++)
+                {
+                    if (i == 4 || i == 6 || i == 8 || i == 10)
+                        UIDBuffer.writeByte(DASH); // Hyphen char code
+
+                    var b:int = ba.readByte();
+                    UIDBuffer.writeByte(ALPHA_CHAR_CODES[(b & 0xF0) >>> 4]);
+                    UIDBuffer.writeByte(ALPHA_CHAR_CODES[(b & 0x0F)]);
+                }
+                return UIDBuffer.toString();
+            }
+
+            return null;
+        }
+
+        /**
+         * A utility method to check whether a String value represents a 
+         * correctly formatted UID value. UID values are expected to be 
+         * in the format generated by createUID(), implying that only
+         * capitalized A-F characters in addition to 0-9 digits are
+         * supported.
+         * 
+         * @param uid The value to test whether it is formatted as a UID.
+         * 
+         * @return Returns true if the value is formatted as a UID.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        public static function isUID(uid:String):Boolean
+        {
+            if (uid != null && uid.length == 36)
+            {
+                for (var i:uint = 0; i < 36; i++)
+                {
+                    var c:Number = uid.charCodeAt(i);
+
+                    // Check for correctly placed hyphens
+                    if (i == 8 || i == 13 || i == 18 || i == 23)
+                    {
+                        if (c != DASH)
+                        {
+                            return false;
+                        }
+                    }
+                    // We allow capital alpha-numeric hex digits only
+                    else if (c < 48 || c > 70 || (c > 57 && c < 65))
+                    {
+                        return false;
+                    }
+                }
+
+                return true;
+            }
+
+            return false;
+        }
+
+        /**
+         * Converts a UID formatted String to a ByteArray. The UID must be in the
+         * format generated by createUID, otherwise null is returned.
+         * 
+         * @param String representing a 128-bit UID
+         * 
+         * @return ByteArray 16 bytes in length representing the 128-bits of the
+         * UID or null if the uid could not be converted.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        public static function toByteArray(uid:String):BinaryData
+        {
+            if (isUID(uid))
+            {
+                var result:BinaryData = new BinaryData();
+
+                for (var i:uint = 0; i < uid.length; i++)
+                {
+                    var c:String = uid.charAt(i);
+                    if (c == "-")
+                        continue;
+                    var h1:uint = getDigit(c);
+                    i++;
+                    var h2:uint = getDigit(uid.charAt(i));
+                    result.writeByte(((h1 << 4) | h2) & 0xFF);
+                }
+                result.position = 0;
+                return result;
+            }
+
+            return null;
+        }
+
+
+        /**
+         * Returns the decimal representation of a hex digit.
+         * @private
+         */
+        private static function getDigit(hex:String):uint
+        {
+            switch (hex) 
+            {
+                case "A": 
+                case "a":           
+                    return 10;
+                case "B":
+                case "b":
+                    return 11;
+                case "C":
+                case "c":
+                    return 12;
+                case "D":
+                case "d":
+                    return 13;
+                case "E":
+                case "e":
+                    return 14;                
+                case "F":
+                case "f":
+                    return 15;
+                default:
+                    return uint(hex);
+            }    
+        }
+    }
+}
\ No newline at end of file