精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-05-09
官方说明,看的真晕,谁有blazeds中文翻译麻烦给一份 In the Consumer component, use the subtopic property to define the subtopic that a message must be sent to for 大概意思,你可以指定一个字面意思的subtopic属性,用通配符来接收不止一个subtopic(ru foo.*可以接收 foo.a,foo.b发布的信息); messaging Service支持单一的一个通配符在subtopic中 如 subtopic="*"表示接收所有信息,*也不写,就什么也收不到 For example, the
foo.*可以收到如 foo.bar foo.baz foo.bar.aaa foo.bar.bbb.ccc这样的producer指定的subtopic的信息
producer 指定foo.*.baz consumer能接收到的信息有 foo.bar.baz foo.aa.baz 而foo.bar.cookie不能受到,应为不匹配
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.messaging.channels.AMFChannel; import mx.messaging.*; import mx.messaging.messages.*; import mx.messaging.events.*; private function useSubtopic():void { var message:AsyncMessage = new AsyncMessage(); producer.subtopic = "chat.fds.newton"; message.body=txt.text; // Generate message. producer.send(message); } //设置channelSet private function init(){ var url="http://localhost:8400/BlazedsMessage/"; //随便的以个blazeds应用 // var myStreamingAMF:StreamingAMFChannel = new StreamingAMFChannel(url+"my-streaming-amf", url+"messagebroker/streamingamf"); var myPollingAMF:AMFChannel = new AMFChannel(url+"my-polling-amf", url+"messagebroker/amfpolling"); myPollingAMF.pollingEnabled = true;//轮询 myPollingAMF.pollingInterval = 1000;//隔多长时间询问一次 1miao var channelSet:ChannelSet = new ChannelSet(); // channelSet.addChannel(myStreamingAMF); channelSet.addChannel(myPollingAMF); producer.channelSet = channelSet; } ]]> </mx:Script> <mx:Producer id="producer" destination="ChatTopic"/> <mx:TextInput x="193" y="38" text="使用subTopic过滤消息" id="txt"/> <mx:Button x="230" y="85" label="send" click="useSubtopic()"/> </mx:Application>
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();logon()"> <mx:Script> <![CDATA[ import mx.messaging.channels.AMFChannel; import mx.messaging.*; import mx.messaging.messages.*; import mx.messaging.events.*; private function messageHandler(event:MessageEvent):void { // Handle message event. ta.text += event.message.body + "\n"; } private function logon():void { consumer.subtopic = "*"; //不写consumer.subtopic就接收不到任何producer发送的subtopic指定的信息(producer指定了subtopic, //consumer必须也指定subtopic才能受到信息) //chat.fds.* 或者 chat.fds.newton都可以受到信息,可以使用通配符 c.*这样就收不到信息 consumer.subscribe(); } private function init(){ var url="http://localhost:8400/BlazedsMessage/"; // var myStreamingAMF:StreamingAMFChannel = new StreamingAMFChannel(url+"my-streaming-amf", url+"messagebroker/streamingamf"); var myPollingAMF:AMFChannel = new AMFChannel(url+"my-polling-amf", url+"messagebroker/amfpolling"); myPollingAMF.pollingEnabled = true; myPollingAMF.pollingInterval = 1000; var channelSet:ChannelSet = new ChannelSet(); // channelSet.addChannel(myStreamingAMF); channelSet.addChannel(myPollingAMF); consumer.channelSet = channelSet; } ]]> </mx:Script> <mx:Consumer id="consumer" destination="ChatTopic" message="messageHandler(event);"/> <mx:TextArea id="ta" width="100%" height="100%"/> </mx:Application> message-config.xml官方说明 To allow subtopics for a destination, set the allow-subtopics element to true in the destination definition in the
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
浏览 3438 次