Package org.vrspace.server.api
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
available
(jakarta.servlet.http.HttpSession session) TODO this needs to be moved in general capabilities controllerorg.springframework.http.ResponseEntity<byte[]>
back
(jakarta.servlet.http.HttpSession session) Navigate backorg.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[]>
org.springframework.http.ResponseEntity<byte[]>
forward
(jakarta.servlet.http.HttpSession session) Navigate forwardorg.springframework.http.ResponseEntity<byte[]>
Get a web pagevoid
quit
(jakarta.servlet.http.HttpSession session) Quit current browserbyte[]
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
-
Field Details
-
PATH
- See Also:
-
-
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 tosession
- 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 lefty
- position from topsession
- 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 upsession
- 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)
-