浏览代码

Всё чётенько! (2)

Alec 4 年之前
父节点
当前提交
29d37d30de
共有 2 个文件被更改,包括 8 次插入8 次删除
  1. 二进制
      out/production/NetWork/com/company/Client.class
  2. 8 8
      src/com/company/Client.java

二进制
out/production/NetWork/com/company/Client.class


+ 8 - 8
src/com/company/Client.java

@@ -25,7 +25,6 @@ public class Client extends Thread {
     @Override
     public void run() {
        while (!isInterrupted()) {
-
            try {
                ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
 
@@ -42,15 +41,16 @@ public class Client extends Thread {
                System.out.print("\033[1;31m\033[40m " + t.Name + ": \u001B[0m ");
                System.out.println(t.Message);
 
-           } catch (IOException exception) {
-               System.out.println(exception.getMessage());
-               clientList.remove(this);
-               break;
-           } catch (ClassNotFoundException exception) {
-               System.out.print("Не смог прочитать данные клиента " + socket.getRemoteSocketAddress().toString() + ": ");
+           } catch (IOException | ClassNotFoundException exception) {
                System.out.println(exception.getMessage());
                clientList.remove(this);
-               break;
+               System.out.println("Disconnected user " + socket.getRemoteSocketAddress().toString());
+               try {
+                   socket.close();
+               } catch (IOException e) {
+                   e.printStackTrace();
+               }
+               return;
            }
        }
     }