val cmdSrc: Source[Message, ActorRef] = Source.actorRef[Message](10, OverflowStrategy.fail)
val wsr: WebSocketRequest = WebSocketRequest(myEndpoint)
val webSocketFlow: Flow[Message, Message, Future[WebSocketUpgradeResponse]] = Http().webSocketClientFlow(wsr)
val webSocketGraph: RunnableGraph[(ActorRef, Future[Done])] = cmdSrc.via(webSocketFlow).toMat(printSink)(Keep.both)
val (actorRef, fd): (ActorRef, Future[Done]) = webSocketGraph.run()
val flow = builder.add(wsl.mapMaterializedValue(f => {
f map {
u => if (u.response.status == StatusCodes.SwitchingProtocols) {
log.info("Switched protocols")
}
else
throw new IllegalStateException("Did not switch")
}
})