📄 chat.java
字号:
package container.chat;
import java.io.*;
import java.util.Hashtable;
import java.util.Enumeration;
import javax.servlet.ServletInputStream;
import javax.servlet.http.*;
import http.*;
public class chat{
HttpStatusCodes HttpStatus=null;
PrintStream sendmsg=null;
Hashtable HttpQuery=null;
static Hashtable chatStream=null;//sdhfgefsdghf
static String ChatMsg="TEST";
String name=null;
String msg=null;
public chat (PrintStream sendmsg,Hashtable chatStream){
this.sendmsg = sendmsg;
this.chatStream=chatStream;
HttpStatus=new HttpStatusCodes();
}
public void getPost(String post){
HttpQuery=javax.servlet.http.HttpUtils.parseQueryString(post);
try{
name = new String( HttpQuery.get("NAME").toString().getBytes("8859_1"));
msg = new String( HttpQuery.get("MSG").toString().getBytes("8859_1"));
}catch (java.io.UnsupportedEncodingException E){}
ChatMsg=name + ": " + msg;
sendAll();
}
public void send(){
sendmsg.print(HttpStatus.toString(200)+"\r\n");
sendmsg.flush();
sendmsg.print(jwsconf.GetMime("XYZ")+"\r\n\r\n" );
sendmsg.flush();
sendmsg.println("<html><head></head><body>");
sendmsg.flush();
String css=
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\n"+
"<style type=\"text/css\">\n"+
"<!--\n"+
".p9 { font-size: 11pt; line-height: 21pt}\n"+
"a:visited { color: #0000FF; text-decoration: none}\n"+
"a:link { color: #0000FF; text-decoration: none}\n"+
"a:hover { color: #FF0000}\n"+
"-->\n"+
"</style>\n";
sendmsg.println(css);
sendmsg.flush();
sendmsg.println("</head><body>");
sendmsg.flush();
String script=
"<SCRIPT LANGUAGE=\"JavaScript1.1\">\n"+
"function scrollWindow( ){this.scroll(0, 65000);}\n"+
"setInterval('scrollWindow()',200);\n"+
"</script>";
sendmsg.println(script);
sendmsg.flush();
String welcome="<p>欢迎光临本聊天室,仅供测试使用!</p>";
sendmsg.println(welcome);
sendmsg.flush();
for(;;){
try {
Thread.sleep(100);
}catch (InterruptedException e){}
}
}
public void sendAll(){
System.out.print("TEST");
synchronized( chatStream ) {
for (Enumeration chats = chatStream.elements(); chats.hasMoreElements(); ) {
PrintStream sendmsg = (PrintStream)chats.nextElement();
sendmsg.println(ChatMsg+"<br>");
sendmsg.flush();
System.out.print(ChatMsg+"<br>");
}
}//synchronized
}//end sendAll()
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -