Class SeleniumController


  • @RestController
    @RequestMapping("/vrspace/api/webbrowser")
    @ConditionalOnProperty(prefix="org.vrspace.server",
                           name="selenium-enabled",
                           havingValue="true")
    public class SeleniumController
    extends ApiBase
    Remote browser support. Receives basic commands, forwards them to the headless browser, creates and returns the screenshot. Screenshots are rendered in 2048x1024 resolution, supposedly optimal to be used as textures.
    Author:
    joe
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String PATH  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean available​(javax.servlet.http.HttpSession session)
      TODO this needs to be moved in general capabilities controller
      org.springframework.http.ResponseEntity<byte[]> back​(javax.servlet.http.HttpSession session)
      Navigate back
      org.springframework.http.ResponseEntity<byte[]> click​(int x, int y, javax.servlet.http.HttpSession session)
      Click on a pixel on the screen.
      org.springframework.http.ResponseEntity<byte[]> close​(javax.servlet.http.HttpSession session)
      Close the browser window/tab.
      org.springframework.http.ResponseEntity<byte[]> enter​(String text, javax.servlet.http.HttpSession session)  
      org.springframework.http.ResponseEntity<byte[]> forward​(javax.servlet.http.HttpSession session)
      Navigate forward
      org.springframework.http.ResponseEntity<byte[]> get​(String url, javax.servlet.http.HttpSession session)
      Get a web page
      void quit​(javax.servlet.http.HttpSession session)
      Quit current browser
      byte[] scroll​(int pixels, javax.servlet.http.HttpSession session)
      Scroll up or down by given number of pixels.
    • Constructor Detail

      • SeleniumController

        public SeleniumController()
    • Method Detail

      • available

        @GetMapping("/available")
        public boolean available​(javax.servlet.http.HttpSession session)
        TODO this needs to be moved in general capabilities controller
        Returns:
        true if remote browsing is available
      • get

        @GetMapping(value="/get",
                    produces="image/png")
        @ResponseBody
        public org.springframework.http.ResponseEntity<byte[]> get​(String url,
                                                                   javax.servlet.http.HttpSession session)
        Get a web page
        Parameters:
        url - web page to browse to
        session - provided by spring
        Returns:
        screenshot of the rendered page
      • click

        @GetMapping(value="/click",
                    produces="image/png")
        @ResponseBody
        public org.springframework.http.ResponseEntity<byte[]> click​(int x,
                                                                     int y,
                                                                     javax.servlet.http.HttpSession session)
        Click on a pixel on the screen. This may do nothing or anything, including opening a new tab.
        Parameters:
        x - position from left
        y - position from top
        session - provided by spring
        Returns:
        screenshot of the rendered page
      • scroll

        @GetMapping(value="/scroll",
                    produces="image/png")
        @ResponseBody
        public byte[] scroll​(int pixels,
                             javax.servlet.http.HttpSession session)
        Scroll up or down by given number of pixels.
        Parameters:
        pixels - positive down, or negative up
        session - provided by spring
        Returns:
        screenshot of the page
      • close

        @GetMapping(value="/close",
                    produces="image/png")
        @ResponseBody
        public org.springframework.http.ResponseEntity<byte[]> close​(javax.servlet.http.HttpSession session)
        Close the browser window/tab. Returns to previous tab if any, or returns no content (http 204 status).
        Parameters:
        session - provided by spring
        Returns:
        screenshot, may be empty if the browser was closed.
      • quit

        @GetMapping("/quit")
        public void quit​(javax.servlet.http.HttpSession session)
        Quit current browser
      • back

        @GetMapping(value="/back",
                    produces="image/png")
        @ResponseBody
        public org.springframework.http.ResponseEntity<byte[]> back​(javax.servlet.http.HttpSession session)
        Navigate back
      • forward

        @GetMapping(value="/forward",
                    produces="image/png")
        @ResponseBody
        public org.springframework.http.ResponseEntity<byte[]> forward​(javax.servlet.http.HttpSession session)
        Navigate forward
      • enter

        @GetMapping(value="/enter",
                    produces="image/png")
        @ResponseBody
        public org.springframework.http.ResponseEntity<byte[]> enter​(String text,
                                                                     javax.servlet.http.HttpSession session)