Last active
October 3, 2016 22:36
-
-
Save schrepfler/c7b2cb1d3f1f5956bc28489fcb45631d to your computer and use it in GitHub Desktop.
Revisions
-
schrepfler renamed this gist
Oct 3, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
schrepfler created this gist
Oct 3, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ object Client extends App with CirceSupport { implicit val system = ActorSystem("client") import system.dispatcher // Create the 'greeter' actor val greeter = system.actorOf(Props[Greeter], "greeter") implicit val materializer = ActorMaterializer() val log = system.log val persistJson = Flow[Json] val start = ByteString.empty val sep = ByteString("\n") val end = ByteString.empty implicit val jsonStreamingSupport = EntityStreamingSupport.json() .withFramingRenderer(Flow[ByteString].intersperse(start, sep, end)) val decoder = Decoder[Json] val jsonFlow = Flow[Json] val subscribeCommand: Json = Json.fromString("{\"command\" : \"subscribeAll\"}") val source: Source[Json, Promise[Option[Json]]] = Source(List(subscribeCommand)) .concatMat(Source.maybe[Json])(Keep.right) val sink = Sink.foreach(s => greeter ! s) val clientFlow: Flow[Nothing, Json, NotUsed] = Flow.fromSinkAndSource(sink, source) Http().singleWebSocketRequest(WebSocketRequest("ws://gtp2betastream.systest.williamhill.plc:8080/eventUpdates"), clientFlow) }