-
-
Save nsdevaraj/9bd094ac172d336004c6 to your computer and use it in GitHub Desktop.
The master file sending orders to all slave processors using localconnection
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
<?xml version="1.0" encoding="utf-8"?> | |
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:s="library://ns.adobe.com/flex/spark" | |
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" | |
addedToStage="init()"> | |
<fx:Script> | |
<![CDATA[ | |
private var sendConn:LocalConnection; | |
private var receiveConn:LocalConnection; | |
private var myCount:int =0; | |
private var channelName:String; | |
private const CHANNEL:String = 'channel'; | |
private const COMMONHANDLER:String = "lcHandler"; | |
private function init():void { | |
sendConn = new LocalConnection(); | |
receiveConn = new LocalConnection(); | |
receiveConn.allowDomain('*'); | |
receiveConn.allowInsecureDomain('*'); | |
receiveConn.client = this; | |
try { | |
receiveConn.connect(CHANNEL+myCount); | |
} catch (error:ArgumentError) { | |
} | |
//always sent to first Slave | |
channelName= CHANNEL+(1).toString(); | |
} | |
public function lcHandler(msg:Object):void { | |
trace('processed at :'+msg.processedAt) | |
trace('result :'+msg.transmittedObj.c) | |
trace('processed by :'+msg.destination ) | |
} | |
protected function sendBtnHandler(event:MouseEvent):void | |
{ | |
var msg:Object= new Object(); | |
var sendObj:Object= new Object(); | |
sendObj.a = 3 | |
sendObj.b = 2 | |
msg.transmittedObj = sendObj; | |
msg.destination = 1; | |
sendConn.send(channelName,COMMONHANDLER,msg); | |
trace(msg.destination+'Message Sent to channel Destination') | |
msg.destination = 2; | |
sendConn.send(channelName,COMMONHANDLER,msg); | |
trace(msg.destination+'Message Sent to channel Destination') | |
} | |
]]> | |
</fx:Script> | |
<s:Button id="sendBtn" click="sendBtnHandler(event)"/> | |
</s:Application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment