예제 #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));
        }