public class MobilePhoneProxy extends Proxy { public static const NAME:String = "MobilePhoneProxy"; public static const GET_PHONE_USER_CALLBACK:String = "getPhoneUserCallBack"; public static const GET_PHONE_TEMPLATE_CALLBACK:String = "getPhoneTemplateCallBack";
private var mobile:RemoteObject; public var op1:Operation; public var op2:Operation;
public function MobilePhoneProxy(data:Object=null) { super(NAME, data);
mobile = new RemoteObject(); mobile.destination = "phone"; mobile.endpoint = "/Project_ydq/messagebroker/amf"; mobile.showBusyCursor = true; //操作定义 op1 = new Operation(); op1.addEventListener(ResultEvent.RESULT, getPhoneUserCallBack);//如果是此事件,则回调此方法 op2 = new Operation(); op2.addEventListener(ResultEvent.RESULT, getPhoneTemplateCallBack); //多个操作加入远程对象 mobile.operations = {"getPhoneUser" : op1,"getPhoneTemplate" : op2};//JAVA对象里的方法 //mobile.addEventListener(ResultEvent.RESULT, showSMSshowSMS); }
private function getPhoneUserCallBack(event:ResultEvent):void { var re:ArrayCollection = event.message.body as ArrayCollection; if(re.length == 0){ this.sendNotification(GET_PHONE_USER_CALLBACK,re); } this.sendNotification(GET_PHONE_USER_CALLBACK,null);
}
private function getPhoneTemplateCallBack(event:ResultEvent):void {
}
/* 获取接收短信的所有用户 */ public function getUserInfo():void { //mobile.getPhoneUser(); op1.send(); }
/* 获取短信模板 */ public function getPhoneTemplate():void { op2.send(); }