资源简介
源码中的经典中的经典哦,好资料啊
jsp无刷新聊天室程序及源代码
非常难得,请抓中一个学习的好机会吧
代码片段和文件信息
/*
* Created on 2004. 3. 9.
*
*/
package chipchat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* @author Mr.Lee
*/
public final class Channel {
/** Chipchat Instance.. */
private ChipChat parent;
/*
* Rooms Operations...
*/
/** Rooms */
private Map rooms = new HashMap();
/**
* Make new room.
* @param roomname The name of room
* @param maxman The maxmum number of person in room
* @param passwd Password
* @param master Administrator id number
* @return New Room Numbers.
* @throws Exception When Room is full.
*/
public Long makeRoom(
final String roomname
final int maxman
final String passwd
final int master)
throws Exception {
Long num = getUniqueNumber();
Room room = new Room(this num roomname maxman passwd master);
synchronized (rooms) {
rooms.put(num room);
}
return num;
}
/**
* Remove Room.
* @param num Unique number of room.
*/
public void removeRoom(final Long num) {
synchronized (rooms) {
rooms.remove(num);
}
}
/**
* Get Room.
* @param num Unique number of room.
* @return Room.
*/
public Room getRoom(final Long num) {
synchronized (rooms) {
return (Room) rooms.get(num);
}
}
/*
* Make Unique Number..
*/
/** Lock object for unique number. */
private object uniqueNumberLock = new object();
/** Number of last maked. */
private long uniqueNum = 0;
/**
* Make unique number.
* @return Unique number
*/
private Long getUniqueNumber() {
long r;
synchronized (uniqueNumberLock) {
r = uniqueNum++;
}
return new Long(r);
}
/*
* Room Lists....
*/
/** Temporary List of room for listing. */
private RoomInfo[] roomList;
/** Whether rooms are changed or not. */
private boolean listChanged = true;
/**
* Set that rooms are changed.
*/
protected void setListChanged() {
listChanged = true;
}
/**
* Get temporary list of rooms.
* @return Temporary list of rooms.
*/
public RoomInfo[] getRoomList() {
if (listChanged) {
makeRoomList();
}
return roomList;
}
/**
* Make new temporary list of rooms.
*/
private void makeRoomList() {
synchronized (rooms) {
if (listChanged) {
RoomInfo[] tmpRoomList = new RoomInfo[rooms.size()];
int c = 0;
Iterator i = rooms.values().iterator();
while (i.hasNext()) {
object value = i.next();
tmpRoomList[c] = new RoomInfo((Room) value);
c++;
}
roomList = tmpRoomList;
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2459 2004-06-30 22:13 chat\channel.jsp
文件 470 2004-06-24 21:33 chat\channelInfo.jsp
文件 196 2004-03-09 20:15 chat\chipchat.css
文件 580 2004-06-30 01:42 chat\communicator.jsp
文件 5980 2004-06-30 22:13 chat\index.jsp
文件 2200 2004-06-29 23:53 chat\input.js
文件 1712 2004-06-30 22:13 chat\login.jsp
文件 692 2004-06-30 22:13 chat\logout.jsp
文件 1373 2004-06-29 00:11 chat\members.js
文件 4664 2004-06-30 22:13 chat\rooms.jsp
文件 419 2004-06-30 22:13 chat\session
文件 136 2004-06-29 22:33 chat\sessionkeeper.jsp
文件 10555 2004-06-30 00:26 chat\view.js
文件 7856 2006-12-06 20:09 chat\chat.jsp
文件 16075 2006-12-07 11:54 chat\chipchat.js
文件 300 2004-06-30 22:27 chat\WEB-INF\web.xm
文件 872 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\User.class
文件 1386 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\ConnectionInfo.class
文件 118 2004-06-30 22:13 chat\WEB-INF\classes\chipchat\chipchat.properties
文件 9272 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\Room.class
文件 1090 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\ChipChat.class
文件 1837 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\ConnectionWaiter.class
文件 2107 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\Msg.class
文件 1273 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\StringUtil.class
文件 1359 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\Env.class
文件 2226 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\Server.class
文件 2782 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\Server$1.class
文件 8289 2004-06-30 22:13 chat\WEB-INF\classes\chipchat\Communicator.class
文件 1307 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\RoomInfo.class
文件 2687 2006-12-28 19:18 chat\WEB-INF\classes\chipchat\Channel.class
............此处省略360个文件信息
- 上一篇:jaxws-api-2.1-1.jar
- 下一篇:RUU刷机方法
评论
共有 条评论