flex 信道连接

package as3.tools
{
 import mx.messaging.ChannelSet;
 import mx.messaging.Consumer;
 import mx.messaging.channels.StreamingAMFChannel;
 import mx.messaging.events.MessageEvent;
 /**
  * 信道请求
  */
 public final class MessageRequest
 {
  /**
   * seed:信道标识
   * messageHandler:处理方法
   */
  public function MessageRequest(seed:String,messageHandler:Function)
  {
   var consumer:Consumer = new Consumer();
            consumer.destination = seed;
            consumer.subtopic = seed;
            var  myStreamingAMF:StreamingAMFChannel = new StreamingAMFChannel("my-streaming-amf", "/aqhb2/messagebroker/streamingamf");
            var channelSet:ChannelSet = new ChannelSet(); 
            channelSet.addChannel(myStreamingAMF); 
            consumer.addEventListener(MessageEvent.MESSAGE,messageHandler);
            consumer.subscribe();
  }
 }
}

你可能感兴趣的:(Flex)