package jp.ac.naka.ec;

import jp.ac.naka.ec.dht.Chord;
import jp.ac.naka.ec.sip.SipCore;

public class Main {

	public static void main(String[] args) {
		
		EntityCollaborator ec = EntityCollaborator.getInstance();
		
		String bootstrapURI = null;
		int bootstrapPort = Chord.PORT;
		/*
		args = new String[4];
		args[0] = "localhost";
		args[1] = "3997";
		args[2] = "3998";
		args[3] = "5070";
		*/
		if (args.length > 0) {
			bootstrapURI = args[0];
		}
		if (args.length > 1) {
			bootstrapPort = Integer.valueOf(args[1]);
		}
		if (args.length > 2) {
			Chord.PORT = Integer.valueOf(args[2]);
		}
		if (args.length > 3) {
			SipCore.PORT = Integer.valueOf(args[3]);
		}
		
		try {
			ec.initiateSipCore();
			if (bootstrapURI != null) {
				ec.initiateDHT(bootstrapURI, bootstrapPort);
				ec.initEntities();
			}
			else {
				ec.initEntities();
				ec.findPeer();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		
		//VideoTransmitterEntity video = new VideoTransmitterEntity();
		//MediaReceiverEntity receiver = new MediaReceiverEntity();
		//ec.addEntity(video);
		//ec.addEntity(receiver);
	}

}
