I have using akka http streams to implement WebSocket server. However, Client sends a lot of data every minute. So the connection is kept alive between client and server.
While implementing web socket handler, I have used flow and sink. And using Sink.seq. A sink is something that keeps on collecting incoming elements until upstream terminates.
How can I avoid it?
implicit val system = ActorSystem("DecoderSystem")
implicit val materializer = ActorMaterializer()
val streamedMsgFuture: Future[Seq[ByteString]] = streamedMsg.runWith(Sink.seq)
streamedMsgFuture.onComplete { completedStream =>
var completeBytestring = new ByteStringBuilder()
//I'm sure there's a better way to do this.. but hey, it's O(n)
completedStream.foreach { x =>
x.foreach { y =>
completeBytestring ++= y
}
}