📄 wholechatroominfo.java
字号:
package chat;import java.util.*;import java.sql.*;public class WholeChatRoomInfo { static Vector rooms=new Vector(); //类型为RoomInfo static Vector wander=new Vector(); //类型为TempInfo static int room_num; static int room_max_num; static int serverport; static int refreshtime; static int reintime; static Vector ticks=new Vector(); //static Vector receivepac=new Vector(); static public boolean findName(String name) { UserTempInfo uInfo=new UserTempInfo(); for(int i=0;i<rooms.size();i++) { RoomInfo rInfo=new RoomInfo(); rInfo=(RoomInfo) rooms.elementAt(i); for(int j=0;j<rInfo.user.size();j++) { uInfo=(UserTempInfo)rInfo.user.elementAt(j); if(name.compareTo(uInfo.getname())==0) return true; } } for(int i=0;i<wander.size();i++) { uInfo=(UserTempInfo)wander.elementAt(i); if(name.compareTo(uInfo.getname())==0) return true; } return false; } static public UserTempInfo getinfobyName(String name) { UserTempInfo uInfo=new UserTempInfo(); for(int i=0;i<rooms.size();i++) { RoomInfo rInfo=new RoomInfo(); rInfo=(RoomInfo) rooms.elementAt(i); for(int j=0;j<rInfo.user.size();j++) { uInfo=(UserTempInfo)rInfo.user.elementAt(j); if(name.compareTo(uInfo.getname())==0) return uInfo; } } return uInfo; }static public int finduserRoom(String name){ for(int i=0;i<WholeChatRoomInfo.rooms.size();i++) { RoomInfo rInfo=new RoomInfo(); rInfo=(RoomInfo)WholeChatRoomInfo.rooms.elementAt(i); for(int j=0;j<rInfo.user.size();j++) { UserTempInfo tempinfo =new UserTempInfo(); tempinfo = (UserTempInfo) rInfo.user.elementAt(j); if(name.compareTo(tempinfo.getname())==0) return i; } } return -1;} public WholeChatRoomInfo() { } static public boolean findtickname(String tickname,int num) { for(int i=0;i<ticks.size();i++) { TickInfo tInfo=new TickInfo(); tInfo=(TickInfo)ticks.elementAt(i); RoomInfo rInfo=(RoomInfo)rooms.elementAt(num); if(tickname.compareTo(tInfo.username)==0 && rInfo.room_name.compareTo(tInfo.roomname)==0) { return true; } } return false; } public boolean InitialRoom() { //从数据库获取有几个room WholeChatRoomInfo.rooms.clear(); DataBean db=new DataBean(); db.connect(); try { //int i=0; String sql="select * from chat_attribute"; ResultSet rs2=db.openRs(sql); if(rs2.next()) { serverport=Integer.parseInt(rs2.getString("port")); reintime=Integer.parseInt(rs2.getString("reintime")); refreshtime=Integer.parseInt(rs2.getString("refreshtime")); } sql="select * from room_info"; ResultSet rs=db.openRs(sql); while(rs.next()) { RoomInfo info=new RoomInfo(); info.setroomname(rs.getString("room_name")); info.setmaxnum(Integer.parseInt(rs.getString("room_max_member"))); WholeChatRoomInfo.rooms.addElement(info); String str=info.room_name; } WholeChatRoomInfo.room_num=WholeChatRoomInfo.rooms.size(); rs.close(); } catch(Exception e) { return false; } return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -