📄 clientthread.java
字号:
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;//线程调试数据
int port = 0;//线程调试数据
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() );//测试
return room;
}
public void run() {
System.out.println("ClientThread count is " + count);
System.out.println("ClientThread port is " + port);
String userIP = s.getInetAddress().toString();//客户机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();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -