var so={
		doMessageComplete: function(){
			function execute(winTarget, fnNameWithParams) {
				var cmd = null;
				cmd = AndroidFunction.JSONs(cmd, "callback.to", winTarget);
				cmd = AndroidFunction.JSONs(cmd, "callback.value", fnNameWithParams);
				AndroidFunction.JsonRun(cmd);
			}			
			execute("window1", "so._doMessageComplete()");			
		},
		_doMessageComplete: function(){
			var found = false;
			
			for (var i = 0; i < this.count(); i++)
			{
				var txt = this.queue[i].msg.body.srd.OCC_Text;
				
				//console.log("so.finding <L=4> from :"+ txt);
				//if (/\<L=4\>/.test(txt))
				if (/(\<L=1\>)|(\<L=2\>)|(\<L=3\>)|(\<L=4\>)/.test(txt))
				{
					found = true;
					break;
				}
			}
			if (!found) {
				//console.log("so.doMessageComplete <L=4> not found");
				this.isPlaying = false;
				return;
			}
			
			while (so.count() > 0)
			{
				var msg = so.pop();
				var txt = msg.msg.body.srd.OCC_Text;
				//console.log('so.hook :  ' + txt + ' ' + so.count());
				try {
					__cb_multicast(msg.ip, msg.msg);
				}catch(e){
					console.log('so.exception: ' + e);
				}
				//if (/\<L=4\>/.test(txt))
				if (/(\<L=1\>)|(\<L=2\>)|(\<L=3\>)|(\<L=4\>)/.test(txt))
					break;					
			}
		},
		isPlaying: false,
		queue: [],
		pop: function()
		{
			var r = this.queue[0];
			this.queue.shift();
			return r;
		},
		end:function()
		{
			var rv ="";
			console.log("so.end() 11111 "+so.count());
			if(so.count() > 0){
				while(so.count() > 0){
					rv += so.pop();	
				}
			}
			console.log("so.end() 22222 "+so.count());
			return rv;
			
		},
		typeValue:"",
		getTypeCheck: function(){
			console.log("so.js  so.getTypeCheck: "+this.typeValue);
			return this.typeValue;
			
		},
		setTypeCheck:function(occtype){
			
			this.typeValue = occtype;
			console.log("so.js  so.setTypeCheck: "+this.typeValue);
		},
		count: function()
		{
				return this.queue.length;
		},
		push: function(data)
		{
			this.queue.push(data);
		},
		launch: function(cmd)
		{
			console.log('so.launch isPlaying : ' + this.isPlaying);
			if (this.isPlaying)
				return;
			this.isPlaying = true;
			
			while (so.count() > 0)
			{
				var msg = so.pop();
				try {
					__cb_multicast(msg.ip, msg.msg);
				}catch(e){
					console.log('so.exception: ' + e);
				}
			}
		}
};

//logcat | busybox grep "so/.\|so.js\|Uncaught"
