?? serverthread.java~1~
字號:
import java.io.*;
import java.util.*;
import java.net.*;
public class ServerThread extends Thread{
DataOutputStream dos;
DataInputStream dis;
Socket socket;
Hashtable peopleList=new Hashtable();
public ServerThread(Socket socket,Hashtable peopleList){
this.socket=socket;
this.peopleList=peopleList;
try{
dos=new DataOutputStream(socket.getOutputStream());
dis=new DataInputStream(socket.getInputStream());
}catch(IOException e){
e.printStackTrace();
}
}
public void run(){
while(true){
String message = null;
try {
message = dis.readUTF();
if(message.startsWith("LOGIN_NAME:")){
//調(diào)用數(shù)據(jù)庫函數(shù),確認用戶
//存線程
}
else if(message.startsWith("PUBLICMESSAGE:")){
//轉(zhuǎn)發(fā)消息
//String content=message.subSequence(message.indexOf(""))
Enumeration enum=peopleList.elements();
while(enum.hasMoreElements()){
((ServerThread)enum.nextElement()).dos.writeUTF(message);
}
}
else if(message.startsWith("PRIVATEMESSAGE:")){
}
else if(message.startsWith("SEND_FILE:")){
}
else if(message.startsWith("AGREE_ACCEPT:")){
}
else if(message.startsWith("DISAGREE_ACCEPT:")){
}
else if(message.startsWith("PEOPLE_LEAVE:")){
}
}
catch (IOException e) {
}
}
}
public static void main(String[] args) {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -