43 lines
		
	
	
		
			877 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			43 lines
		
	
	
		
			877 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
								 | 
							
								config({
							 | 
						||
| 
								 | 
							
								  log:{
							 | 
						||
| 
								 | 
							
								    time:true
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								})
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								port(DIR.IP('udp://localhost'))
							 | 
						||
| 
								 | 
							
								connect(DIR.IP('udp://localhost:5568?secure=12:34:56:78:00:01'));
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function ag() {
							 | 
						||
| 
								 | 
							
								  this.goto=null;
							 | 
						||
| 
								 | 
							
								  this.root=null;
							 | 
						||
| 
								 | 
							
								  this.act = {
							 | 
						||
| 
								 | 
							
								    check: function () {
							 | 
						||
| 
								 | 
							
								      log('Waiting');
							 | 
						||
| 
								 | 
							
								      this.root=myNode();
							 | 
						||
| 
								 | 
							
								      var links=link(DIR.IP('%'));
							 | 
						||
| 
								 | 
							
								      if (links && links.length) 
							 | 
						||
| 
								 | 
							
								        this.goto=links[0];
							 | 
						||
| 
								 | 
							
								      else sleep(500);
							 | 
						||
| 
								 | 
							
								    },
							 | 
						||
| 
								 | 
							
								    move: function () {
							 | 
						||
| 
								 | 
							
								      log('Going to '+this.goto);
							 | 
						||
| 
								 | 
							
								      moveto(DIR.NODE(this.goto))
							 | 
						||
| 
								 | 
							
								    },
							 | 
						||
| 
								 | 
							
								    back: function () {
							 | 
						||
| 
								 | 
							
								      log('Going back to '+this.root);
							 | 
						||
| 
								 | 
							
								      moveto(DIR.NODE(this.root))      
							 | 
						||
| 
								 | 
							
								    },
							 | 
						||
| 
								 | 
							
								    end: function () {
							 | 
						||
| 
								 | 
							
								      log('Terminating');
							 | 
						||
| 
								 | 
							
								      kill();
							 | 
						||
| 
								 | 
							
								    },
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								  this.trans = { check:function () { return this.goto?'move':'check' },
							 | 
						||
| 
								 | 
							
								                 move:'back',
							 | 
						||
| 
								 | 
							
								                 back:'end' }
							 | 
						||
| 
								 | 
							
								  this.next = 'check';
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								start()
							 | 
						||
| 
								 | 
							
								print(create(ag,{},2))
							 |