import java.util.List;
import java.util.Iterator;
import java.util.Vector;

import Six.Sixp.Client.*;

public class Program {

	/**
	 * @param args
	 */
	
	private static String OS = System.getProperty("os.name").toLowerCase();
	
	public static void main(String[] args) {
		run(args);
	}

	public static void run(String[] args) {

		if (args.length != 4) {
			System.out
					.println("Syntax: Six.Sixp.Client.Demo server:port userid pwd requestfile");
			return;
		}

		String server = args[0];
		String userid = args[1];
		String pwd = args[2];
		String requestfile = args[3];

		String workdir = System.getProperty("user.dir");

		String host = server.split(":")[0];
		int port = Integer.parseInt(server.split(":")[1]);
		
		List<String> prls;
		ParseUtil p = new ParseUtil();

		if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) {
			prls = p.parseFile(workdir + "/" + requestfile);
		} else {
			prls = p.parseFile(workdir + "\\" + requestfile);
		}

		Iterator<String> iterator = prls.iterator();

		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}
		
		Vector<SixpServerSettings> l = new Vector<SixpServerSettings>();
		try
		{
			SixpServerSettings ss = new SixpServerSettings(host, port);
			l.add(ss);
			StreamingClientDemo sd = new StreamingClientDemo(l, null, ReconnectStrategy.ReconnectResubscribe, 15,prls, workdir, userid, pwd);
		
			sd.RunAsync();
		}
		catch (SixpExceptionInvalidParameter e)
		{
			System.out.println("Invalid parameter exception is:" + e);
		}
	}
}
