You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2018/11/21 22:08:25 UTC
[royale-asjs] branch develop updated: add disableCompression to
CompressedRemoteObject
This is an automated email from the ASF dual-hosted git repository.
carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 392a65f add disableCompression to CompressedRemoteObject
392a65f is described below
commit 392a65f7e8256a06c0b42b55812fd191f33cb8d2
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Wed Nov 21 23:08:18 2018 +0100
add disableCompression to CompressedRemoteObject
---
.../mx/rpc/remoting/CompressedRemoteObject.as | 14 ++++++++--
.../apache/royale/net/CompressedRemoteObject.as | 32 ++++++++++++++++------
.../royale/net/remoting/amf/AMFNetConnection.as | 4 ++-
3 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/rpc/remoting/CompressedRemoteObject.as b/frameworks/projects/MXRoyale/src/main/royale/mx/rpc/remoting/CompressedRemoteObject.as
index a9833bd..a56fd97 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/rpc/remoting/CompressedRemoteObject.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/rpc/remoting/CompressedRemoteObject.as
@@ -37,6 +37,15 @@ package mx.rpc.remoting
*/
public class CompressedRemoteObject extends RemoteObject
{
+ /**
+ * disable the compression if true
+ *
+ * defaults to false
+ *
+ * @royalesuppresspublicvarwarning
+ */
+ public static var disableCompression:Boolean;
+
[ArrayElementType("String")]
/**
* @royalesuppresspublicvarwarning
@@ -144,7 +153,7 @@ package mx.rpc.remoting
private function deserializeResult(result:*, operation:AbstractOperation):* // NO PMD
{
COMPILE::SWF{
- if (result is ByteArray) {
+ if (!disableCompression && result is ByteArray) {
var byteArray:ByteArray = result as ByteArray;
byteArray.uncompress();
return byteArray.readObject();
@@ -155,7 +164,7 @@ package mx.rpc.remoting
COMPILE::JS
{
- if (result is Array)
+ if (!disableCompression && result is Array)
{
// --- Transform the number array into a bytearray
var bytearray:Uint8Array = new Uint8Array(result);
@@ -163,6 +172,7 @@ package mx.rpc.remoting
var data:AMFBinaryData = new AMFBinaryData(window["pako"]["inflate"](bytearray));
// --- store the inflated data object in result
result = data.readObject();
+
return result;
}
else
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/CompressedRemoteObject.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/CompressedRemoteObject.as
index bb42dce..b9a7aac 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/CompressedRemoteObject.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/CompressedRemoteObject.as
@@ -47,16 +47,27 @@ package org.apache.royale.net
super();
}
+ /**
+ * disable the compression if true
+ *
+ * defaults to false
+ *
+ * @royalesuppresspublicvarwarning
+ */
+ public static var disableCompression:Boolean;
+
override public function resultHandler(param:Object):void
{
COMPILE::JS
{
- // --- Transform the number array into a bytearray
- var bytearray:Uint8Array = new Uint8Array(param.body);
+ if(!disableCompression) {
+ // --- Transform the number array into a bytearray
+ var bytearray:Uint8Array = new Uint8Array(param.body);
- // --- uncompress the bytearray to get the real object (tree) and create the AMFBinaryData with it
- var data:AMFBinaryData = new AMFBinaryData(window["pako"]["inflate"](bytearray));
- param.body = data.readObject();
+ // --- uncompress the bytearray to get the real object (tree) and create the AMFBinaryData with it
+ var data:AMFBinaryData = new AMFBinaryData(window["pako"]["inflate"](bytearray));
+ param.body = data.readObject();
+ }
// --- dispatch the ResultEvent like in the standard RemoteObject with the inflated result object
dispatchEvent(new ResultEvent(ResultEvent.RESULT, param.body));
}
@@ -64,9 +75,14 @@ package org.apache.royale.net
COMPILE::SWF
{
// --- SWF not tested
- var byteArray:ByteArray = param.body as ByteArray;
- byteArray.uncompress();
- dispatchEvent(new ResultEvent(ResultEvent.RESULT, byteArray.readObject()));
+ if(!disableCompression) {
+ var byteArray:ByteArray = param.body as ByteArray;
+ byteArray.uncompress();
+ dispatchEvent(new ResultEvent(ResultEvent.RESULT, byteArray.readObject()));
+ } else
+ {
+ dispatchEvent(new ResultEvent(ResultEvent.RESULT, param.body));
+ }
}
}
}
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFNetConnection.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFNetConnection.as
index d09ec28..c91317b 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFNetConnection.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFNetConnection.as
@@ -79,7 +79,9 @@ public class AMFNetConnection
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
- * @productversion Royale 0.9.5
+ * @productversion Royale 0.9.5
+ *
+ * @royalesuppresspublicvarwarning
*/
public var errorClass:Class;