-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap up tasks of loading local and remote nomadhelper.html
alongside comparision into Proxy (reference #57)
- Loading branch information
1 parent
584bf88
commit 8af10c7
Showing
6 changed files
with
99 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...an.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/proxy/ProxyNomadHelperComparer.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package model.proxy | ||
{ | ||
import model.proxy.login.ProxyLogin; | ||
|
||
import org.apache.royale.utils.async.PromiseTask; | ||
import org.apache.royale.utils.async.SequentialAsyncTask; | ||
import org.puremvc.as3.multicore.patterns.proxy.Proxy; | ||
|
||
import utils.NomadHelperLoaderTasks; | ||
import utils.UtilsCore; | ||
|
||
public class ProxyNomadHelperComparer extends Proxy | ||
{ | ||
public static const NAME:String = "ProxyNomadHelperComparer"; | ||
public static const NOTE_COMPARE_RESULTS:String = NAME + "NoteCompareResults"; | ||
|
||
public function ProxyNomadHelperComparer() | ||
{ | ||
super(NAME); | ||
|
||
setData(false); | ||
} | ||
|
||
public function isNomadHelpersEqual():Boolean | ||
{ | ||
return Boolean(getData()); | ||
} | ||
|
||
public function compareNomadHelpers():void | ||
{ | ||
var loginProxy:ProxyLogin = facade.retrieveProxy(ProxyLogin.NAME) as ProxyLogin; | ||
if (loginProxy.isNomadHelperUrlExists()) | ||
{ | ||
var nomadHelperUrlTasks:NomadHelperLoaderTasks = new NomadHelperLoaderTasks(); | ||
nomadHelperUrlTasks.done(function(task:PromiseTask):void { | ||
if (nomadHelperUrlTasks.failed) | ||
{ | ||
setData(false); | ||
sendNotification(NOTE_COMPARE_RESULTS, getData()); | ||
} | ||
else if (nomadHelperUrlTasks.completed) | ||
{ | ||
compareNomadHelperUrl(nomadHelperUrlTasks.completedTasks[0], nomadHelperUrlTasks.completedTasks[1]); | ||
} | ||
}); | ||
nomadHelperUrlTasks.run(loginProxy.config.config.nomad_helper_url); | ||
} | ||
} | ||
|
||
private function compareNomadHelperUrl(nomadHelperUrlTask:PromiseTask, nomadHelperUrlTask2:PromiseTask):void | ||
{ | ||
var nomadHelperUrlHash:PromiseTask = UtilsCore.computeHash(nomadHelperUrlTask.result.target.element.responseText); | ||
var nomadHelperUrlHash2:PromiseTask = UtilsCore.computeHash(nomadHelperUrlTask2.result.target.element.responseText); | ||
|
||
var sequentialHashTask:SequentialAsyncTask = new SequentialAsyncTask([ | ||
nomadHelperUrlHash, | ||
nomadHelperUrlHash2 | ||
]); | ||
|
||
sequentialHashTask.done(function(task:PromiseTask) { | ||
if (sequentialHashTask.failed) | ||
{ | ||
setData(false); | ||
} | ||
else if (sequentialHashTask.completed) | ||
{ | ||
var hash1:String = sequentialHashTask.completedTasks[0].data; | ||
var hash2:String = sequentialHashTask.completedTasks[1].data; | ||
|
||
var isNomadHelpersEqual:Boolean = hash1 == hash2; | ||
setData(isNomadHelpersEqual); | ||
} | ||
|
||
sendNotification(NOTE_COMPARE_RESULTS, getData()); | ||
}) | ||
sequentialHashTask.run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters