diff --git a/src/main/scala/akkahttp/HttpFileEcho.scala b/src/main/scala/akkahttp/HttpFileEcho.scala index 0ebeff58..fc5494d1 100644 --- a/src/main/scala/akkahttp/HttpFileEcho.scala +++ b/src/main/scala/akkahttp/HttpFileEcho.scala @@ -16,6 +16,7 @@ import spray.json.{DefaultJsonProtocol, RootJsonFormat} import java.io.File import java.nio.file.Paths import java.time.LocalTime +import scala.annotation.unchecked.uncheckedStable import scala.collection.parallel.CollectionConverters.* import scala.concurrent.duration.* import scala.concurrent.{Await, Future} @@ -24,7 +25,7 @@ import scala.util.{Failure, Success} trait JsonProtocol extends DefaultJsonProtocol with SprayJsonSupport { - @unchecked + @uncheckedStable final case class FileHandle(fileName: String, absolutePath: String, length: Long) object FileHandle extends ((String, String, Long) => FileHandle) { diff --git a/src/main/scala/akkahttp/WebsocketChatEcho.scala b/src/main/scala/akkahttp/WebsocketChatEcho.scala index c8770223..d0facba9 100644 --- a/src/main/scala/akkahttp/WebsocketChatEcho.scala +++ b/src/main/scala/akkahttp/WebsocketChatEcho.scala @@ -66,8 +66,9 @@ object WebsocketChatEcho extends App with ClientCommon { logger.info(s"Server received: $text") Future.successful(text) case TextMessage.Streamed(textStream) => - textStream.runReduce(_ + _) - .flatMap(Future.successful) + textStream.runReduce(_ + _).flatMap(Future.successful) + case bm: BinaryMessage => throw new Exception(s"Binary message: $bm cannot be handled") + case other => throw new Exception(s"Unhandled message type: $other cannot be handled") } .via(Flow.fromSinkAndSourceCoupled(inSink, outSource)) // Optional msg aggregation diff --git a/src/main/scala/akkahttp/WebsocketEcho.scala b/src/main/scala/akkahttp/WebsocketEcho.scala index 571b6b7a..9ac41a79 100644 --- a/src/main/scala/akkahttp/WebsocketEcho.scala +++ b/src/main/scala/akkahttp/WebsocketEcho.scala @@ -137,7 +137,7 @@ object WebsocketEcho extends App with WebSocketDirectives with ClientCommon { .repeat(s"Heartbeat response: ${LocalDateTime.now()}") .throttle(1, 1.seconds) .wireTap(msg => logger.info(s"Sending to client: $msg")) - .map(TextMessage.Strict) + .map(TextMessage.Strict.apply) .watchTermination()((_, done) => done.onComplete { case Failure(err) => logger.info(s"Heartbeat server flow failed: $err") case _ => logger.info(s"Heartbeat server flow terminated")