/// <summary> /// Let the robot walk /// </summary> /// <param name="robotId"></param> /// <param name="degree"></param> /// <param name="speed"></param> /// <param name="distance"></param> public static void Walk(string robotKey, RobotControlSignal signal, IHubContext context) { string signalMessage = JsonConvert.SerializeObject(signal); List<Robot> robots = robotDB.GetConnectedRobots(robotKey); foreach (Robot robot in robots) { string connectionId = robot.ConnectionId; var client = context.Clients.Client(connectionId); if (client != null) { client.send(signalMessage); } } }
public JsonResult WalkRobot(string robotKey, string degree, string speed, string distance, string pan, string tilt) { // Walk Robot to certain distance var context = GlobalHost.ConnectionManager.GetHubContext<RobotSignalHub>(); RobotControlSignal robotSignal = new RobotControlSignal() { Distance = double.Parse(distance), Speed = double.Parse(speed), Degree = double.Parse(degree), Pan = double.Parse(pan), Tilt = double.Parse(tilt) }; RobotSignalHub.Walk(robotKey, robotSignal, context); return Json(robotSignal, JsonRequestBehavior.AllowGet); }