scalafmt all

This commit is contained in:
efim
2023-04-25 10:25:36 +04:00
parent 0a721b135f
commit 2244f38348
10 changed files with 133 additions and 129 deletions

View File

@@ -14,15 +14,14 @@ trait Auth[F[_]] {
/** for middleware that converts sessionId into PlayerId
*/
def authUser
: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[F], (PlayerID, RoomID)]
def authUser: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[F], (PlayerID, RoomID)]
/** Get sessionId for accessing a room
* @param roomPassword
* \- requirement to get access to the room
*
* check that room exists, password is valid call to add user to the players
* create session mapping and return cookie
* check that room exists, password is valid call to add user to the players create session
* mapping and return cookie
*/
def joinRoom(
roomName: String,
@@ -75,9 +74,8 @@ object Auth {
???
}
override def authUser: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[
F
], (PlayerID, RoomID)] = {
override def authUser
: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[F], (PlayerID, RoomID)] = {
// check authcookie presence, exchange it for playerID ad roomID
???
}

View File

@@ -24,9 +24,11 @@ object MyHttpService {
AuthedRoutes.of {
case GET -> Root / "subscribe" as (playerId, roomId) => {
val send: Stream[IO, WebSocketFrame] =
Stream
Stream
.emits(TestModels.testChangesList)
.covary[IO].metered(1.second).map(state => WebSocketFrame.Text(state.asJson.noSpaces))
.covary[IO]
.metered(1.second)
.map(state => WebSocketFrame.Text(state.asJson.noSpaces))
val receive: Pipe[IO, WebSocketFrame, Unit] = _.evalMap {
case WebSocketFrame.Text(text, _) => Sync[IO].delay(println(text))
@@ -64,7 +66,7 @@ object MyHttpService {
Forbidden(error)
case Right(authCookie) => {
IO(println(s"> logging in ${data.nickname} to ${data.roomName}")) >>
Ok().map(_.addCookie(authCookie))
Ok().map(_.addCookie(authCookie))
}
}
} yield resp

View File

@@ -15,8 +15,7 @@ trait RoomService[F[_]] {
def getRoom(roomID: RoomID): F[Option[Room]]
}
class InMemoryRoomService[F[_]: Sync](stateRef: Ref[F, Map[RoomID, Room]])
extends RoomService[F] {
class InMemoryRoomService[F[_]: Sync](stateRef: Ref[F, Map[RoomID, Room]]) extends RoomService[F] {
override def createRoom(newRoom: Room): F[Either[RoomError, Room]] = {
stateRef.modify { rooms =>
rooms.get(newRoom.id) match {