scalafmt all
This commit is contained in:
@@ -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
|
||||
???
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user