📄 msg.java
字号:
package chatweb;
public class Msg {
public static final int TYPE_MSG = 0;
public static final int TYPE_CUSTOMMSG = 1;
public static final int TYPE_INFO = 2;
public static final int TYPE_ERROR = 3;
public static final int TYPE_WSPSND = 11;
public static final int TYPE_WSPRCV = 12;
public static final int TYPE_USERS = 20;
public static final int TYPE_ADMIN = 30;
public static final int TYPE_ADMINCHANGE = 31;
public static final int TYPE_KEEPQUIET = 40;
public static final int TYPE_KICKOUT = 41;
private final int to;
private final String writer;
private final String msg;
private final int msgType;
public Msg(
final int msgType,
final int to,
final String msg,
final String writer) {
this.to = to;
this.msg = msg;
this.writer = writer;
this.msgType = msgType;
}
public final String getString(final int id) {
if (to == -1 || to == id || id == -2) {
switch (msgType) {
case Msg.TYPE_MSG :
return ("MSG:" + writer + ">" + msg + "\r\n");
case Msg.TYPE_CUSTOMMSG :
return ("CUSTOM:" + writer + ">" + msg + "\r\n");
case Msg.TYPE_INFO :
return ("INFO:" + writer + ">" + msg + "\r\n");
case Msg.TYPE_USERS :
return ("USERS:" + msg + "\r\n");
case Msg.TYPE_ERROR :
return ("ERROR:" + msg + "\r\n");
case Msg.TYPE_WSPSND :
return ("WSPSND:" + writer + ">" + msg + "\r\n");
case Msg.TYPE_WSPRCV :
return ("WSPRCV:" + writer + ">" + msg + "\r\n");
case Msg.TYPE_ADMIN :
return ("ADMIN:" + msg + "\r\n");
case Msg.TYPE_ADMINCHANGE :
return ("ADMCG:" + msg + "\r\n");
case Msg.TYPE_KEEPQUIET :
return ("KEEPQUIET:" + writer + ">" + msg + "\r\n");
case Msg.TYPE_KICKOUT :
return ("KICKOUT:" + writer + ">" + msg + "\r\n");
default :
System.out.println(
"msgtype :" + msgType);
return null;
}
} else {
return null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -