initial way to run the server:
sbt:backend> assembly java -jar backend/target/scala-3.2.0/backend-assembly-0.1.0-SNAPSHOT.jar
This commit is contained in:
@@ -22,16 +22,12 @@ object MyHttpService {
|
||||
|
||||
val authedRoomRoutes: AuthedRoutes[(PlayerID, RoomID), IO] =
|
||||
AuthedRoutes.of {
|
||||
case GET -> Root / subscribe as (playerId, roomId) => {
|
||||
case GET -> Root / "subscribe" as (playerId, roomId) => {
|
||||
val send: Stream[IO, WebSocketFrame] =
|
||||
{
|
||||
val a = Stream
|
||||
Stream
|
||||
.emits(TestModels.testChangesList)
|
||||
.covary[IO].metered(5.second).map(state => WebSocketFrame.Text(state.asJson.noSpaces))
|
||||
Stream
|
||||
.awakeEvery[IO](1.seconds)
|
||||
.map(_ => WebSocketFrame.Text("text"))
|
||||
}
|
||||
|
||||
val receive: Pipe[IO, WebSocketFrame, Unit] = _.evalMap {
|
||||
case WebSocketFrame.Text(text, _) => Sync[IO].delay(println(text))
|
||||
case other => Sync[IO].delay(println(other))
|
||||
@@ -40,13 +36,13 @@ object MyHttpService {
|
||||
}
|
||||
case GET -> Root / "vote" / vote as (playerId, roomId) => {
|
||||
// TODO forward these to the service implementation
|
||||
Ok(s">> got $vote from $playerId in $roomId")
|
||||
IO(println(s">> got $vote from $playerId in $roomId")) >> Ok()
|
||||
}
|
||||
case GET -> Root / "end-voting" as (playerId, roomId) => {
|
||||
Ok(s">> got request to end voting from $playerId in $roomId")
|
||||
IO(println(s">> got request to end voting from $playerId in $roomId")) >> Ok()
|
||||
}
|
||||
case GET -> Root / "new-poll" as (playerId, roomId) => {
|
||||
Ok(s">> got request to start new voting from $playerId in $roomId")
|
||||
IO(println(s">> got request to start new voting from $playerId in $roomId")) >> Ok()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +51,7 @@ object MyHttpService {
|
||||
|
||||
val authenticationRoute = HttpRoutes
|
||||
.of[IO] {
|
||||
case req @ POST -> Root / login => {
|
||||
case req @ POST -> Root / "login" => {
|
||||
for {
|
||||
data <- req.as[Requests.LogIn]
|
||||
authResult <- auth.accessRoom(
|
||||
@@ -76,7 +72,6 @@ object MyHttpService {
|
||||
}
|
||||
} yield resp
|
||||
}
|
||||
case _ => Ok("hello")
|
||||
}
|
||||
|
||||
(authenticationRoute <+> authMiddleware(authedRoomRoutes)).orNotFound
|
||||
|
||||
Reference in New Issue
Block a user