| private final List talkers;//排队发言人数Talker private final List manager;//会议室治理员 private Talker currentTalker;//当前发言人 private String cid;//会议室id private String title;//会议室主题 private String intro;//会议室简介 private String owner;//会议室创建人 private int maxUser;//最大在线人数 private int interval;//最大刷新时间间隔 private String vrtype;//访问权限 private String vrvalue;//访问值 private String announce; private String password;//房间进入密码 private int status;//会议室状态 private String filePath; //private Thread thread; private boolean isStop=false; public ChatService() { this.msgs=new ArrayList(); this.users=new ArrayList(); this.talkers=new ArrayList(); this.manager=new ArrayList(); this.maxUser=1000;//最大1000人同时 this.interval=1000*60*5;//5分钟以前的信息 } /** * 停止所有会议室 * */ public static void clear() { if(!service.isEmpty()) { Iterator it=service.values().iterator(); while(it.hasNext()) { ChatService chat=(ChatService)it.next(); chat.stop(); } } service.clear(); } /** * 创建一个会议室 * @param name 会议室ID * @return */ public static ChatService create(String name) { ChatService ret=null; if(service.containsKey(name)) { ChatService s=(ChatService)service.get(name); s.stop(); service.remove(name); } if(service.size(){ ret=new ChatService(); service.put(name,ret); } return ret; } /** * 停止某个会议室 * @param name 会议室ID * @return */ public static boolean close(String name) { ChatService chatRoom=ChatService.get(name); if(chatRoom!=null) { chatRoom.stop(); service.remove(name); } return true; } /** * 获得一个会议室信息 * @param name 会议室ID * @return */ public static ChatService get(String name) { if(service.containsKey(name))return (ChatService)service.get(name); else return null; } public void run() { // TODO Auto-generated method stub //this.thread=Thread.currentThread(); while(!isStop) { //System.out.println("开始监控一个会议室!" this.title); this.flash(); try{ Thread.sleep(5000); } catch(Exception e) { e.printStackTrace(); } } //System.out.println("结束!"); } public void stop() { this.flashAll(); isStop=true; } //会议室中有人发言 public boolean talk(Chat chat) { boolean ret=false; if(canTalk(chat.getSender())) { this.msgs.add(chat); ret=true; } return ret; } public boolean exit(ChatUser user) { talk(geneSystemMsg(user.getUserName() "退出了会议室!")); return this.users.remove(user); } } //刷新信息,保存会议信息
|
| 共6页: 上一页 [1] [2] 3 [4] [5] [6] 下一页 |
评论加载中…