<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The NoteBook of EricKong

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      611 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks
    The Messaging Service lets client applications send and receive messages from other clients. In this example, create a Flex application that sends and receives messages from the same BlazeDS destination.
    Define the messaging destination in WEB-INF/flex/messaging-config.xml, as the following example shows:
    <destination id="MessagingDestination" channels="my-amf-poll"/>

    Define the my-amf-poll channel in WEB-INF/flex/services-config.xml, as the following example shows:
    <channel-definition id="my-amf-poll" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpoll" class="flex.messaging.endpoints.AMFEndpoint"/>
        
    <properties>
         
    <polling-enabled>true</polling-enabled>
         
    <polling-interval-seconds>1</polling-interval-seconds>
        
    </properties>
    </channel-definition>

    This channel definition creates a polling channel with a polling interval of 1 second. Therefore, the client sends a poll message to the server every second to request new messages. Use a polling channel because it is the easiest way for the client to receive updates. Other options include polling with piggybacking, long-polling, and streaming.The following Flex client application uses the Producer component to send a message to the destination, and the Consumer component to receive messages sent to the destination. To send the message, the Producer first creates an instance of the AsyncMessage class and then sets its body property to the message. Then, it calls the Producer.send() method to send it. To receive messages, the Consumer first calls the Consumer.subscribe() method to subscribe to messages sent to a specific destination.
    <?xml version="1.0"?>
    <!-- intro\intro_messaging.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    width
    ="100%" height="100%"
    creationComplete
    ="consumer.subscribe();">
    <mx:Script>
    <![CDATA[
    import mx.messaging.events.MessageFaultEvent;
    import mx.messaging.events.MessageEvent;
    import mx.messaging.messages.AsyncMessage;
    import mx.messaging.Producer;
    import mx.messaging.Consumer;
    // Send the message in response to a Button click.
    private function sendMessage():void {
    var msg:AsyncMessage = new AsyncMessage();
    msg.body = "Foo";
    producer.send(msg);
    }
    // Handle the received message.
    private function messageHandler(event:MessageEvent):void {
    ta.text += "Consumer received message: "+ event.message.body + "\n";
    }
    // Handle a message fault.
    private function faultHandler(event:MessageFaultEvent):void {
    ta.text += "Received fault: " + event.faultString + "\n";
    }
    ]]>
    </mx:Script>
    <mx:Producer id="producer" destination="MessagingDestination" fault="faultHandler(event);"/>
    <mx:Consumer id="consumer" destination="MessagingDestination" fault="faultHandler(event);" message="messageHandler(event);"/>
    <mx:Button label="Send" click="sendMessage();"/>
    <mx:TextArea id="ta" width="100%" height="100%"/>
    </mx:Application>
    Compile the client application into a SWF file by using Flex Builder or the mxmlc compiler, and then deploy it to
    your web application.
    posted on 2011-06-29 11:58 Eric_jiang 閱讀(306) 評論(0)  編輯  收藏 所屬分類: Flex
    主站蜘蛛池模板: 一级毛片免费毛片一级毛片免费| 青苹果乐园免费高清在线| 亚洲AV日韩AV永久无码免下载| 亚洲视频免费观看| 久久精品国产亚洲AV未满十八| 亚洲午夜久久久久久噜噜噜| 国产啪精品视频网免费| 黄页网站在线观看免费| 亚洲综合在线视频| 免费永久看黄在线观看app| 国产精品免费看久久久 | 久久精品国产亚洲AV电影| 最近免费中文字幕视频高清在线看| 成年免费a级毛片| 亚洲成人福利在线观看| 亚洲中文字幕无码专区| 国产成人免费网站| 国内永久免费crm系统z在线| 亚洲AV无码男人的天堂| 久久亚洲精品无码VA大香大香| 亚洲无码黄色网址| 啦啦啦中文在线观看电视剧免费版 | 毛片基地看看成人免费| 亚洲精品亚洲人成在线| 亚洲黑人嫩小videos| 亚洲成人一区二区| 搡女人真爽免费视频大全| 国产麻豆成人传媒免费观看| 美女啪啪网站又黄又免费| 亚洲色无码专区一区| 久久夜色精品国产噜噜亚洲AV| a级亚洲片精品久久久久久久 | 久久亚洲国产精品123区| 妞干网在线免费观看| 222www免费视频| 免费国产在线视频| 亚洲一区二区三区免费| 国产成人亚洲毛片| 亚洲精品无码久久久久牙蜜区| 亚洲AV无码乱码麻豆精品国产| 久久精品国产亚洲精品2020|