blazeds聊天

我网上找了个flex做的聊天室 SharedObject,服务器也没处理数据,谁高我用Producer与Consumer怎么让
服务器处理数据
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">
	
	<mx:Producer id="producer" destination="chat">
		
	</mx:Producer>
	
	<mx:Consumer id="consumer" destination="chat" message="messagehandle(event)">
		
	</mx:Consumer>
	<mx:Script>
		<![CDATA[
			import mx.messaging.events.MessageAckEvent;
			import mx.messaging.events.ChannelFaultEvent;
			import mx.messaging.events.ChannelEvent;
			import mx.messaging.ChannelSet;
			import mx.messaging.channels.AMFChannel;
			import mx.messaging.channels.StreamingAMFChannel;
			import mx.messaging.events.MessageFaultEvent;
			
			import mx.messaging.messages.AsyncMessage;
			import mx.messaging.events.MessageEvent;
			public function init(){
				initChannel();
				consumer.subscribe();
				producer.addEventListener(MessageFaultEvent.FAULT,error);
				
			
			}
			private function addEvent(){
//				producer.addEventListener(ChannelEvent.CHANNEL_CONNECT,channelConnection);
//				producer.addEventListener(ChannelEvent.CHANNEL_DISCONNECT,channelDisconnect);
//				producer.addEventListener(ChannelFaultEvent.CHANNEL_FAULT,channelFault);
//				producer.addEventListener(MessageAckEvent.ACKNOWLEDGE
				
				
			}
			
			
			public function initChannel(){
				var myStreamingAMF:StreamingAMFChannel = new StreamingAMFChannel("my-streaming-amf", "messagebroker/streamingamf");
				var myPollingAMF:AMFChannel = new AMFChannel("my-polling-amf", "messagebroker/amfpolling");
				myPollingAMF.pollingEnabled = true;
				myPollingAMF.pollingInterval = 2000;
				var channelSet:ChannelSet = new ChannelSet();
				channelSet.addChannel(myStreamingAMF);
				channelSet.addChannel(myPollingAMF);
				consumer.channelSet = channelSet;				
				producer.channelSet = channelSet;
			}
			public function messagehandle(event:MessageEvent){
				ta.text+=event.message.body+"\n";
			}
			private function sendMessage():void{
				
				var message:AsyncMessage=new AsyncMessage();
				message.body=userName.text+":"+msg.text;
				producer.send(message);
				msg.text=""
				
			}
			public function error(event:MessageFaultEvent){
				trace(event.message);
			}
		]]>
	</mx:Script>
	<mx:VBox width="540">
		

	<mx:TextArea id="ta" width="520" height="200">
		
	</mx:TextArea>
	<mx:TextInput id="userName" width="518" text="ss">
		
	</mx:TextInput>
	<mx:TextInput id="msg" width="520" text="s">
		
	</mx:TextInput>
	<mx:Button label="send" click="sendMessage()">
		
	</mx:Button>
	</mx:VBox>
</mx:Application>

 服务器只用配置一下message-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" 
    class="flex.messaging.services.MessageService">

    <adapters>
        <adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
        <!-- <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/> -->
    </adapters>

    <default-channels>
        <channel ref="my-polling-amf"/>
    </default-channels>
<!--上边的是已经有的,下边是我加上的,就2行呵呵-->
	<destination id="chat">
		
	</destination>
</service>

 

你可能感兴趣的:(xml,Flex,jms,Adobe,actionscript)