You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

VncController.java 2.0 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.educoder.bridge.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.educoder.bridge.service.VncService;
  4. import com.educoder.bridge.utils.Base64Util;
  5. import com.educoder.bridge.utils.JedisUtil;
  6. import com.educoder.bridge.utils.PortUtil;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiOperation;
  9. import io.swagger.annotations.ApiParam;
  10. import org.slf4j.Logger;
  11. import org.slf4j.LoggerFactory;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.http.MediaType;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.RestController;
  17. @Api(value = "vnc控制器", hidden = true)
  18. @RestController
  19. @RequestMapping("/vnc")
  20. public class VncController {
  21. @Autowired
  22. private VncService vncService;
  23. private static final Logger logger = LoggerFactory.getLogger(VncController.class);
  24. @RequestMapping(path = "/getvnc")
  25. @ApiOperation(value = "图形界面", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
  26. public JSONObject getvnc(
  27. @ApiParam(name = "tpiID", required = true, value = "实训实例的ID") @RequestParam String tpiID,
  28. @ApiParam(name = "containers", required = true, value = "需要使用的容器,base64编码") @RequestParam String containers)
  29. throws Exception{
  30. JSONObject response = new JSONObject();
  31. String podName = "vnc-" + tpiID;
  32. containers = Base64Util.decode(containers);
  33. // 为vnc分配port
  34. String port = JedisUtil.hget("port", podName);
  35. if (port == null) {
  36. port = PortUtil.getPort() + "";
  37. JedisUtil.hset("port", podName, port);
  38. }
  39. vncService.getvnc(tpiID, containers);
  40. response.put("code", 0);
  41. response.put("port", port);
  42. return response;
  43. }
  44. }

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...