You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
package nova.monadic_sfx.util
|
|
|
|
import monix.bio.Task
|
|
import nova.monadic_sfx.AppTypes
|
|
import nova.monadic_sfx.implicits._
|
|
import sttp.client._
|
|
import sttp.client.httpclient.monix.MonixWebSocketHandler
|
|
|
|
// class WebSocket()(implicit backend: AppTypes.HttpBackend) {
|
|
|
|
// // val source = for {
|
|
|
|
// // } yield ()
|
|
// }
|
|
object WebSocket {
|
|
|
|
def apply()(implicit backend: AppTypes.HttpBackend) = {
|
|
Task
|
|
.deferAction(implicit s =>
|
|
IOUtils.toIO(
|
|
basicRequest.get(uri"").openWebsocketF(MonixWebSocketHandler())
|
|
)
|
|
)
|
|
.flatMap { r =>
|
|
val ws = r.result
|
|
// val source = Observable.repeatEvalF(ws.receive)
|
|
val source2 = ws.observableSource
|
|
// ws.send()
|
|
val source3 = source2.map {
|
|
case Left(value) => ()
|
|
case Right(value) => value
|
|
}
|
|
// ws.send()
|
|
// val sink = new Observer[WebSocketFrame] {
|
|
|
|
// override def onNext(elem: WebSocketFrame): Future[Ack] = ws.send(elem)
|
|
|
|
// override def onError(ex: Throwable): Unit = ex.printStackTrace()
|
|
|
|
// override def onComplete(): Unit = ws.close
|
|
|
|
// }
|
|
Task.unit
|
|
}
|
|
}
|
|
|
|
}
|