Package model

Source Code of model.Model

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();
  }   
}
TOP

Related Classes of model.Model

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.