<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 閱讀(311) 評論(0)  編輯  收藏 所屬分類: Flex
    主站蜘蛛池模板: 中国精品一级毛片免费播放| 人成午夜免费视频在线观看| 亚洲国产精品无码久久一线| 91高清免费国产自产拍2021| 亚洲精品无码成人片久久不卡| 全黄性性激高免费视频| 中国毛片免费观看| 亚洲视频在线观看2018| 久久伊人亚洲AV无码网站| 在线日本高清免费不卡| 美女隐私免费视频看| 亚洲人成人伊人成综合网无码| 无码欧精品亚洲日韩一区夜夜嗨| 中文字幕乱码免费看电影| 亚洲人成小说网站色| 亚洲香蕉网久久综合影视| 青青视频观看免费99| 国产精品永久免费视频| 亚洲国产高清视频在线观看| 亚洲精品无码av天堂| 日本XXX黄区免费看| 国内精品免费视频精选在线观看| 亚洲欧美日韩自偷自拍| 亚洲AV日韩AV永久无码下载| 国产99视频精品免费视频7| 99xxoo视频在线永久免费观看| 美女黄色毛片免费看| 亚洲av无码片区一区二区三区 | 国产亚洲精品自在久久| 毛片免费vip会员在线看| 最新亚洲成av人免费看| 美女黄色毛片免费看| 国产精品亚洲精品青青青| 水蜜桃亚洲一二三四在线| 亚洲国产V高清在线观看| 女人被男人桶得好爽免费视频| 久久一本岛在免费线观看2020| 四虎影视久久久免费| 成人婷婷网色偷偷亚洲男人的天堂 | 国产精品亚洲精品日韩动图| 亚洲国产精品综合久久久|