| 
					
				 | 
			
			
				@@ -1,8 +1,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.company; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.io.InputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.io.OutputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.management.Attribute; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.net.Socket; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.nio.charset.StandardCharsets; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -10,8 +9,8 @@ import java.util.Scanner; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class Client extends Thread { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Socket socket; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private InputStream inputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private OutputStream outputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ObjectInputStream inputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ObjectOutputStream outputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Список всех подключенных слиентов 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private List<Client> clientList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -21,30 +20,37 @@ public class Client extends Thread { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.socket = socket; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.clientList = clientList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        inputStream = socket.getInputStream(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        outputStream = socket.getOutputStream(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        inputStream = new ObjectInputStream(socket.getInputStream()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        outputStream = new ObjectOutputStream(socket.getOutputStream()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-       byte []buffer = new byte[READ_BUFFER_SIZE]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (!isInterrupted()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               inputStream.read(buffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               Transport t = (Transport) inputStream.readObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Client client : clientList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                   if (client != this) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                       client.outputStream.write(buffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   if (client.socket != this.socket) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       client.outputStream.writeObject(t); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       client.outputStream.flush(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               System.out.print("Клиент " + socket.getLocalAddress().getHostAddress() + " "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               System.out.println(new String(buffer, StandardCharsets.UTF_8)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               System.out.print("\033[1;31m\033[40m " + t.Name + ": \u001B[0m "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               System.out.println(t.Message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (IOException exception) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               System.out.println("Не смог прочитать данные клиента " + socket.getLocalAddress().getHostAddress()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               System.out.println(exception.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               clientList.remove(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           } catch (ClassNotFoundException exception) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               System.out.print("Не смог прочитать данные клиента " + socket.getRemoteSocketAddress().toString() + ": "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               System.out.println(exception.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               clientList.remove(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |