package model;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import helper.ObservableSupport;
public class Model {
private static ObservableSupport observer;
public Receive receiver;
public Send sender;
public static ObservableSupport getObserver(){
return observer;
}
public Model(){
observer = new ObservableSupport();
Config.loadConfig();
receiver = new Receive();
sender = new Send();
}
public static int generateID() {
long time = System.currentTimeMillis();
Enumeration<NetworkInterface> net;
byte[] mac = null;
try {
net = NetworkInterface.getNetworkInterfaces();
if(net.hasMoreElements())
mac = net.nextElement().getHardwareAddress();
} catch (SocketException e) {
e.printStackTrace();
}
int random = (int)Math.round( Math.random() * 10000 );
return String.valueOf(time).hashCode() ^ mac.toString().hashCode() ^ String.valueOf(random).hashCode();
}
}