Пример #1
0
        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}");
            }
        }
Пример #2
0
        public async Task HandleAsync(BindRobot command, string clientIP)
        {
            var robot = await _robotService.GetRobotAsync(command.ID);

            robot?.Bind(clientIP);
        }
Пример #3
0
        public async Task <ActionResult> GetRobotByIdAsync(int id)
        {
            var robot = await _robotService.GetRobotAsync(id);

            return(NullEntityCheckResponse(robot));
        }