Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Sep 25, 2024
1 parent d9897da commit a67939b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions examples3/src/main/scala/sttp/client4/examples/WebSocketOx.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ import sttp.ws.WebSocketFrame

@main def wsOxExample =
def useWebSocket(ws: SyncWebSocket): Unit =
supervised {
supervised:
val inputs = Source.fromValues(1, 2, 3).map(i => WebSocketFrame.text(s"Frame no $i"))
val (wsSource, wsSink) = asSourceAndSink(ws)
fork {
inputs.pipeTo(wsSink)
}
wsSource.foreach { frame =>
fork:
inputs.pipeTo(wsSink, propagateDone = true)
wsSource.foreach: frame =>
println(s"RECEIVED: $frame")
}
}

val backend = DefaultSyncBackend()
try
Expand Down

0 comments on commit a67939b

Please sign in to comment.