feat(ui): Websocket

Added simple websocket. Serverside websocket logic isnt in the usersession
This commit is contained in:
LQ63
2025-11-21 17:11:16 +01:00
committed by Janis
parent 2bc50664e0
commit 09cc96141d
4 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
package controllers
import actor.KnockOutWebSocketActor
import org.apache.pekko.actor.{ActorRef, ActorSystem, Props}
import org.apache.pekko.stream.Materializer
import play.api.*
import play.api.libs.streams.ActorFlow
import play.api.mvc.*
import javax.inject.*
@Singleton
class WebsocketController @Inject()(
cc: ControllerComponents,
)(implicit system: ActorSystem, mat: Materializer) extends AbstractController(cc) {
object KnockOutWebSocketActorFactory {
def create(out: ActorRef) = {
Props(new KnockOutWebSocketActor(out))
}
}
def socket() = WebSocket.accept[String, String] { request =>
ActorFlow.actorRef { out =>
println("Connect received")
KnockOutWebSocketActorFactory.create(out)
}
}
}