var app_mod = require("./app");

var arr = ["192.168.1.58:8365"];
function App(appid){
	this.appid_ = appid;
	this.app_ = app_mod.Create(this.appid_,arr);
	var self =this;
	this.app_.on('open',function(){
		console.log("app.started.at."+appid);
		setTimeout(function(){
			self.app_.Stop();
			setTimeout(function(){
				start(self.appid_);
			},3000);
		},3000);
	})
	this.app_.on("client_in",function(id,addr){
		
	})
	this.app_.on("client_data",function(cid,buf){
		
	})
	this.app_.on("client_out",function(id){
		
	})
	this.app_.on("app_data",function(id,buf){

	})
	this.app_.on('close',function(err){
		console.log("app.close.at."+self.appid_+".with.err={"+err+"}");
		
	})
	this.app_.Start();
}
function start(appid){
	new App(appid);
	
	/**/
}
for(var i =0;i<5;i++){
	start("test1_app_" + i);
}

