Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class ClientHandler implements Runnable {
- Scanner scn = new Scanner(System.in);
- public String name;
- final DataInputStream dis;
- final DataOutputStream dos;
- Socket s;
- boolean isloggedin;
- // constructor
- public ClientHandler(Socket s, String name, DataInputStream dis, DataOutputStream dos) {
- this.dis = dis;
- this.dos = dos;
- this.name = name;
- this.s = s;
- this.isloggedin = true;
- }
- @Override
- public void run() {
- received = "";
- while (true) {
- try {
- while (!received.equals("exit")) {
- received = dis.readUTF();
- textArea.append(name + ":\n" + received + "\n");
- }
- if (received.equals("exit")) {
- this.isloggedin = false;
- this.s.close();
- break;
- }
- } catch (IOException e) {
- // e.printStackTrace();
- }
- }
- try {
- this.dis.close();
- this.dos.close();
- } catch (IOException e) {
- // e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement