搭建flex + blazeds 最简单的messaging例子:简易聊天室
来源:互联网 发布:搞笑电影推荐 知乎 编辑:程序博客网 时间:2024/05/21 21:47
flex + blazeds messaging应用很广泛,比如实时聊天,collaborationapplication。在BlazeDS turnkey (https://www.adobe.com/cfusion/entitlement/index.cfm?e=lc_blazeds)就有一个CollaborationDashboard sample。
该sampleshow how you can use the Message Service to build collaborative applications.To try this sample, open the application in two different browser windows andnotice how selections made in one window are reflected in the other window.
下面讲解怎样搭建flex +blazeds最简单的messaging例子:简易聊天室
1. 在tomcat里创建一个web app (e.g. blazeds),然后把blazeds.war里的东东全部copy到该目录。
2. 修改WEB-INF/flex/messaging-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-streaming-amf"/>
<channel ref="my-polling-amf"/>
</default-channels>
<destination id="chat"/>
</service>
3. 在WEB-INF/flex/services-config.xml里的<channels>里添加下列代码
<channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">
<endpoint class="flex.messaging.endpoints.StreamingAMFEndpoint" url="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf"/>
</channel-definition>
4. restart tomcat
5. 创建flexproject (link to this blazeds web app),mxml file的代码如下
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="subscribe();" height="432" width="686">
<mx:Script>
<![CDATA[
import mx.messaging.messages.*;
import mx.messaging.events.*;
private function subscribe():void {
consumer.subscribe();
}
privatevar begintime:Date;
privatevar endtime:Date;
private functionmessageHandler(event:MessageEvent):void{
ta.text +=event.message.body;
endtime=new Date();
var elapse:Number=endtime.valueOf()-begintime.valueOf();
ta.text+=" --耗时:"+elapse+"毫秒" +"\n";
}
private function sendMessage():void {
var message:AsyncMessage = new AsyncMessage();
message.body =userName.text +": " +msg.text;
producer.send(message);
msg.text = "";
begintime=new Date();
}
]]>
</mx:Script>
<mx:Producerid="producer" destination="chat"/>
<mx:Consumer id="consumer" destination="chat" message="messageHandler(event)"/>
<mx:TextArea id="ta" width="640" height="231" x="13.5" y="37"/>
<mx:TextInput id="userName" x="100" y="275" width="200" text="Eric Han"/>
<mx:TextInput id="msg" width="546" x="98" y="318" />
<mx:Label text="UserName" x="10" y="275" width="80"/>
<mx:Label text="message" x="10" y="320" width="80"/>
<mx:Button label="Send" click="sendMessage();" x="318.5" y="377"/>
</mx:Application>
- 搭建flex + blazeds 最简单的messaging例子:简易聊天室
- Java+blazeds+Flex的例子
- Java+blazeds+Flex的例子
- Java+blazeds+Flex的例子
- Java+blazeds+Flex的例子
- 转:Java+blazeds+Flex的例子 .
- 最简单的flex & bison例子
- 使用blazeds实现java与flex通信的简单例子实现
- FLEX Blazeds 环境搭建
- Ubuntu下用apache+perl搭建最简单的聊天室
- UDP传输:简易聊天室的搭建。。。
- 简易聊天室三 欢迎界面的搭建
- 搭建简易在线聊天室
- swoole搭建简易聊天室
- Flex 与 C# socket 通信(最简单的例子)
- epoll 搭建简单的聊天室
- Workerman搭建简单的聊天室
- Flex与Java通信 BlazeDS方式 最详尽的解析
- linux 下 apache 相关访问策略的实现
- 共创建了多少个对象:String s="a"+"b"+"c"+"d";
- Ubuntu 10.4下安装JDK和Eclipse(手动安装)
- hive优化总结
- 映射网络驱动器
- 搭建flex + blazeds 最简单的messaging例子:简易聊天室
- stm32 I2C问题 I2C_CheckEvent()
- 首选项代码重复利用
- 第二章 Closure javascript注解
- 使用Struts2.2.3.1出现的问题
- 语法分析
- 平台调用P-INVOKE(三)--(封送结构体)
- 批处理及PHP编写目录下的统计文件行数及个数
- 万能指南针(android版本)