fix bugs
This commit is contained in:
		
							parent
							
								
									6bf43409e4
								
							
						
					
					
						commit
						76fe86a3bc
					
				| @ -198,10 +198,10 @@ | ||||
| 
 | ||||
|       function getBoatLog(e) | ||||
|       { | ||||
|          let cmd = prompt("enter command"); | ||||
|          // let cmd = prompt("enter command"); | ||||
|          let boat = getDataFomEl(e.target); | ||||
|          console.log("send cmd", boat, cmd); | ||||
|          conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";" + cmd); | ||||
|          // console.log("send cmd", boat, cmd); | ||||
|          // conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";" + cmd); | ||||
| 
 | ||||
|          conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";servotrim:0"); | ||||
|          conn.send(passEl.value + ";sendcmd;" + boat['id'] + ";servotrim:1"); | ||||
|  | ||||
| @ -130,15 +130,16 @@ async def getlog(client, data): | ||||
| 
 | ||||
| async def sendcmd(data): | ||||
|     """send command to boat""" | ||||
|     for b in Boats: | ||||
|         if b['id'] == data[2]: | ||||
|             del data[0] | ||||
|             del data[1] | ||||
|             del data[2] | ||||
|             print(data) | ||||
|             data = ";".join(data) | ||||
|             await sendToBoat(b, data + "\n") | ||||
|             return | ||||
|     if len(data) > 3: | ||||
|         for b in Boats: | ||||
|             if b['id'] == data[2]: | ||||
|                 del data[0] | ||||
|                 del data[1] | ||||
|                 del data[2] | ||||
|                 print(data) | ||||
|                 data = ";".join(data) | ||||
|                 await sendToBoat(b, data + "\n") | ||||
|                 return | ||||
| 
 | ||||
| async def kick_client(clientId): | ||||
|     """kick a client""" | ||||
| @ -159,7 +160,7 @@ async def on_message(message, client): | ||||
|     data = message.replace('\n', '').split(';') | ||||
|     if data[0] != client["id"]: | ||||
|         print("invalid id: " + str(data[0]) + " != " + str(client["id"])) | ||||
|     else: | ||||
|     elif len(data) >= 2: | ||||
|         if   data[1] == "boats": | ||||
|             await echo_boats(client) | ||||
|         elif data[1] == "ctrl": | ||||
| @ -192,6 +193,8 @@ async def on_message(message, client): | ||||
|             print("WARN: invalid command (admin): '" + data[1] + "'") | ||||
|         else: | ||||
|             print("WARN: invalid command (" + client['id'] + "): '" + data[1] + "'") | ||||
|     else: | ||||
|         print("WARN: to little arguments") | ||||
| 
 | ||||
| async def new_client(clientId, ws): | ||||
|     """handler for every new client connection""" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user