|
@@ -5,12 +5,15 @@ import java.net.ServerSocket;
|
|
import java.net.Socket;
|
|
import java.net.Socket;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Scanner;
|
|
|
|
|
|
public class Main {
|
|
public class Main {
|
|
|
|
+ private static List<Client> clients = new ArrayList<>();
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
|
|
|
- List<Client> clients = new ArrayList<>();
|
|
|
|
|
|
+ AdminWrite adminWrite = new AdminWrite();
|
|
|
|
+ adminWrite.start();
|
|
|
|
|
|
try {
|
|
try {
|
|
ServerSocket ss = new ServerSocket(9125);
|
|
ServerSocket ss = new ServerSocket(9125);
|
|
@@ -32,4 +35,26 @@ public class Main {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static class AdminWrite extends Thread {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Scanner scanner = new Scanner(System.in);
|
|
|
|
+ while (!isInterrupted()) {
|
|
|
|
+ String message = scanner.nextLine();
|
|
|
|
+
|
|
|
|
+ Transport t = new Transport();
|
|
|
|
+ t.Name = "ADMIN";
|
|
|
|
+ t.Message = message;
|
|
|
|
+ for (Client client : clients) {
|
|
|
|
+ try {
|
|
|
|
+ client.outputStream.writeObject(t);
|
|
|
|
+ client.outputStream.flush();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|