circe codec derivation to models
This commit is contained in:
@@ -4,7 +4,8 @@ import cats.effect._
|
||||
import cats.syntax.all._
|
||||
import org.http4s._, org.http4s.dsl.io._, org.http4s.implicits._
|
||||
import org.http4s.websocket.WebSocketFrame
|
||||
import io.circe.generic.auto._
|
||||
// import io.circe.generic.auto._
|
||||
import io.circe.syntax._
|
||||
import org.http4s.circe.CirceEntityDecoder._
|
||||
import scala.concurrent.duration._
|
||||
import org.http4s.server.websocket.WebSocketBuilder
|
||||
@@ -23,9 +24,14 @@ object MyHttpService {
|
||||
AuthedRoutes.of {
|
||||
case GET -> Root / subscribe as (playerId, roomId) => {
|
||||
val send: Stream[IO, WebSocketFrame] =
|
||||
{
|
||||
val a = 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))
|
||||
|
||||
Reference in New Issue
Block a user