Added WebUI observer, added route to see latestOutput. For some reason the WebUI Observer doesn't execute it's methods for writing stuff into latestOutput. This has something to do with how the threads work

This commit is contained in:
LQ63
2025-10-12 15:05:40 +02:00
parent 30fb50c3b8
commit 9098b7c4e3
6 changed files with 546 additions and 20 deletions

View File

@@ -1,9 +1,11 @@
package controllers
import javax.inject._
import play.api._
import play.api.mvc._
import javax.inject.*
import play.api.*
import play.api.mvc.*
import de.knockoutwhist.KnockOutWhist
import de.knockoutwhist.control.ControlHandler
import de.knockoutwhist.ui.tui.TUIMain
/**
* This controller creates an `Action` to handle HTTP requests to the
@@ -24,18 +26,21 @@ class HomeController @Inject()(val controllerComponents: ControllerComponents) e
def index(): Action[AnyContent] = {
if (!initial) {
initial = true
ControlHandler.addListener(WebUI)
KnockOutWhist.main(new Array[String](_length = 0))
}
Action { implicit request: Request[AnyContent] => {
Ok(views.html.main.apply("KnockoutWhist")(views.html.))
}
Action { implicit request =>
Ok(views.html.index.apply())
}
}
def ingame(): Action[AnyContent] = {
Action { implicit request: Request[AnyContent] => {
Ok(views.html.tui.apply())
Action { implicit request =>
Ok(views.html.tui.apply(WebUI.latestOutput))
}
}
def showTUI(): Action[AnyContent] = Action { implicit request =>
Ok(views.html.tui.render(WebUI.latestOutput))
}
}