@@ -0,0 +1,1181 @@
+package pro.simpleproject.core.intra.model;%0A%0Aimport java.util.LinkedHashMap;%0Aimport java.util.Map;%0A%0Aimport pro.simpleproject.core.intra.server.ServerExecutor;%0A%0Apublic class IntraModel %7B%0A%0A%09private static final Map%3CString, IntraContact%3E contacts = new LinkedHashMap%3C%3E();%0A%0A%09public static IntraContact setContact(String addr, int port) %7B%0A%09%09IntraContact contact = contacts.get(addr);%0A%09%09if (contact == null) %7B%0A%09%09%09contact = new IntraContact(addr, port);%0A%09%09%09contacts.put(contact.getAddress(), contact);%0A%09%09%7D else if (contact.getPort() == 0) %7B%0A%09%09%09contact.setPort(port);%0A%09%09%7D%0A%09%09return contact;%0A%09%7D%0A%0A%09public static IntraContact setContact(String addr) %7B%0A%09%09IntraContact contact = new IntraContact(addr);%0A%09%09return contacts.put(contact.getAddress(), contact);%0A%09%7D%0A%0A%09public static IntraContact getContact(String addr) %7B%0A%09%09return contacts.get(addr);%0A%09%7D%0A%0A%09public static boolean hasContact(String addr) %7B%0A%09%09return contacts.containsKey(addr);%0A%09%7D%0A%0A%09public static void removeContact(String addr) %7B%0A%09%09IntraContact c = contacts.remove(addr);%0A%09%09if (c != null) %7B%0A%09%09%09c.close();%0A%09%09%7D%0A%09%7D%0A%0A%09public static void close() %7B%0A%09%09for (IntraContact c : contacts.values()) %7B%0A%09%09%09c.close();%0A%09%09%7D%0A%09%09ServerExecutor.close();%0A%09%7D%0A%0A%7D%0A

Create IntraModel.java