Class SeleniumController

java.lang.Object
org.vrspace.server.api.ApiBase
org.vrspace.server.api.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 final String
     

    Fields inherited from class org.vrspace.server.api.ApiBase

    API_ROOT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

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

    Methods inherited from class org.vrspace.server.api.ApiBase

    currentUserName

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SeleniumController

      public SeleniumController()
  • Method Details

    • available

      @GetMapping("/available") public boolean available(jakarta.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, jakarta.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, jakarta.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, jakarta.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(jakarta.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(jakarta.servlet.http.HttpSession session)
      Quit current browser
    • back

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

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

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