|
@ -4,14 +4,27 @@ import java.io.InputStreamReader; |
|
|
import java.io.OutputStreamWriter; |
|
|
import java.io.OutputStreamWriter; |
|
|
import java.io.PrintWriter; |
|
|
import java.io.PrintWriter; |
|
|
import java.net.ServerSocket; |
|
|
import java.net.ServerSocket; |
|
|
|
|
|
import java.net.Socket; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ClientHandler implements Runnable { |
|
|
public class ClientHandler implements Runnable { |
|
|
private Server server; |
|
|
|
|
|
private ServerSocket connectionToClient; |
|
|
|
|
|
|
|
|
private ChatServer chatServer; |
|
|
|
|
|
private Socket connectionToClient; |
|
|
private String name; |
|
|
private String name; |
|
|
private BufferedReader fromClientReader; |
|
|
private BufferedReader fromClientReader; |
|
|
private PrintWriter toClientWriter; |
|
|
private PrintWriter toClientWriter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ClientHandler(ChatServer chatServer, Socket connectionToClient) { |
|
|
|
|
|
this.chatServer = chatServer; |
|
|
|
|
|
this.connectionToClient = connectionToClient; |
|
|
|
|
|
name = connectionToClient.getInetAddress().getHostAddress(); |
|
|
|
|
|
new Thread(this).start(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|
// TODO Auto-generated method stub |
|
|
// TODO Auto-generated method stub |
|
|