package com.chatroom.runtimeconfig;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import flex.messaging.MessageBroker;
import flex.messaging.MessageDestination;
import flex.messaging.services.MessageService;
/**
* Simplistic implementation of a chat room management service. Clients can add rooms,
* and obtain a list of rooms. The interesting part of this example is the "on-the-fly"
* creation of a message destination. The same technique can be used to create DataService
* and Remoting destinations.
*/
public class ChatRoomService {
private List<String> rooms;
private static MsgProduceThread thread;
public ChatRoomService()
{
rooms = Collections.synchronizedList(new ArrayList<String>());
}
public List<String> getRoomList()
{
return rooms;
}
public void start(String dests) {
System.out.println("dests : " + dests);
if(dests != null && dests.length() > 0){
if (thread == null) {
thread = new MsgProduceThread(dests);
thread.start();
}
}
}
public void stop() {
thread.running = false;
thread = null;
}
public void createRoom(String id) {
if (roomExists(id))
{
throw new RuntimeException("Room already exists");
}
// Create a new Message destination dynamically
String serviceId = "message-service";
MessageBroker broker = MessageBroker.getMessageBroker(null);
MessageService service = (MessageService) broker.getService(serviceId);
MessageDestination destination = (MessageDestination) service.createDestination(id);
if (service.isStarted())
{
destination.start();
}
rooms.add(id);
}
public boolean roomExists(String id)
{
int size = rooms.size();
for (int i=0; i<size; i++)
{
if ( ((String)rooms.get(i)).equals(id) )
{
return true;
}
}
return false;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Flex 消息推送实例,动态创建Destination.rar (53个子文件)
Flex 消息推送实例,动态创建Destination
DynamicDest
WebContent
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 2KB
flex
messaging-config.xml 531B
services-config.xml 4KB
remoting-config.xml 706B
lib
commons-codec-1.3.jar 46KB
flex-rds-server.jar 53KB
commons-httpclient-3.0.1.jar 273KB
flex-messaging-core.jar 671KB
flex-messaging-opt.jar 20KB
commons-logging.jar 37KB
flex-messaging-proxy.jar 65KB
flex-messaging-remoting.jar 18KB
flex-messaging-common.jar 94KB
flexRoot
framework_4.1.0.16076.swf 1021KB
swfobject.js 25KB
history
historyFrame.html 798B
history.css 365B
history.js 24KB
sparkskins_4.1.0.16076.swf 68KB
spark_4.1.0.16076.swf 491KB
rpc_4.1.0.16076.swf 203KB
osmf_flex.4.0.0.13495.swf 147KB
CreateDest.html 5KB
ChatApp.swf 84KB
ChatApp.html 5KB
textLayout_1.1.0.604.swf 257KB
playerProductInstall.swf 657B
CreateDest.swf 83KB
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.wst.common.component 487B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 503B
org.eclipse.jdt.core.prefs 395B
src
com
chatroom
runtimeconfig
MsgProduceThread.java 1KB
ChatRoomService.java 2KB
.project 1KB
.classpath 841B
build
classes
com
chatroom
runtimeconfig
ChatRoomService.class 3KB
MsgProduceThread.class 2KB
DynamicDestClient
.actionScriptProperties 1KB
.flexProperties 360B
html-template
index.template.html 6KB
swfobject.js 25KB
history
historyFrame.html 798B
history.css 365B
history.js 24KB
playerProductInstall.swf 657B
.settings
org.eclipse.core.resources.prefs 88B
src
CreateDest.mxml 2KB
ChatApp.mxml 3KB
.project 684B
libs
共 53 条
- 1
眼炸毛
- 粉丝: 1
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页