public async Task HandleAsync(Drive command, string clientIP) { var robot = await _robotService.GetRobotAsync(command.RobotID); if (robot == null) { return; } if (robot.BoundTo == clientIP) { var packet = Packet.Create($"{command.LEDs.Description()}{command.LeftMotor}{command.RightMotor}"); await robot.WriteAsync(packet.ToRawData()); Debug.WriteLine($"Drive payload: {packet.Payload}"); } else { Debug.WriteLine($"Client does not own the robot with ID {command.RobotID}"); } }
public async Task HandleAsync(BindRobot command, string clientIP) { var robot = await _robotService.GetRobotAsync(command.ID); robot?.Bind(clientIP); }
public async Task <ActionResult> GetRobotByIdAsync(int id) { var robot = await _robotService.GetRobotAsync(id); return(NullEntityCheckResponse(robot)); }