?? clientthread.java
字號(hào):
package freech.core;
import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import freech.action.Action;
import freech.room.Room;
public class ClientThread extends Thread {
private Socket s = null;
int count = 0;//線(xiàn)程調(diào)試數(shù)據(jù)
int port = 0;//線(xiàn)程調(diào)試數(shù)據(jù)
public ClientThread(Socket s, int i, int port) {
this.s = s;
this.count = i;
this.port = port;
}
private Room getRoom() {
//port<--->room
String port1 = String.valueOf( port);
Room room = (Room)Server.svr.getRtop().get( port1);
System.out.println("房間名"+room.getName() );//測(cè)試
return room;
}
public void run() {
System.out.println("ClientThread count is " + count);
System.out.println("ClientThread port is " + port);
String userIP = s.getInetAddress().toString();//客戶(hù)機(jī)IP地址
int userPort = s.getPort();
System.out.println("瀏覽器IP= " + userIP + " 端口= " + userPort);
try {
PrintStream out = new PrintStream(s.getOutputStream());
HttpDecoder request = new HttpDecoder(s);
Action action = new Action(out,getRoom(), request);
if (request.getAction() != null) {
if (request.getAction().equals("")) {
action.index();
}else if(request.getAction() .equals( "login")){
action.login() ;
}else if(request.getAction() .equals( "talk")){
action.talk() ;
} else if (request.getAction().equals("dotalk")) {
action.dotalk();
} else if (request.getAction().equals("list")) {
action.list();
} else if (request.getAction().equals("mainchat")) {
action.mainchat(s );
return;
} else {
action.index();
}
}
out.flush();
out.close() ;
s.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -