<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
    主站蜘蛛池模板: 99国产精品永久免费视频 | 日韩免费高清播放器| 国产成人亚洲精品播放器下载| 亚洲午夜在线播放| 亚洲一区电影在线观看| 亚洲成a人片77777群色| www.亚洲日本| 亚洲熟妇成人精品一区| 蜜桃传媒一区二区亚洲AV| 精品国产亚洲第一区二区三区 | 亚洲人成网77777亚洲色| 狠狠综合久久综合88亚洲| 亚洲午夜无码久久久久| 亚洲成AV人片在线观看无码 | 又黄又爽的视频免费看| 波多野结衣中文一区二区免费| 亚洲国产综合久久天堂| 国产偷国产偷亚洲清高动态图| 久久精品国产亚洲夜色AV网站| 亚洲高清免费在线观看| 亚洲三级视频在线观看 | 亚洲国产一成人久久精品| 亚洲国产精品无码久久SM| 亚洲国语精品自产拍在线观看 | 亚洲AV无码专区在线播放中文| 久久国产精品亚洲一区二区| 97se亚洲综合在线| 精品亚洲国产成人| 羞羞漫画页面免费入口欢迎你| 国产区在线免费观看| 十八禁无码免费网站| 18禁成年无码免费网站无遮挡| 亚洲免费视频播放| 香蕉视频亚洲一级| 99在线免费观看| 182tv免费观看在线视频| 日韩在线a视频免费播放| 久久伊人亚洲AV无码网站| 亚洲精品视频久久| 色天使亚洲综合一区二区| 手机看片国产免费永久|