Hei Viktor, Sure. Sorry if it was not clear.
My goal is to use SSE to feed an EventSource on JavaScript side. On the example given, the tick call correctly produces events on the line, but the actorFlow, none. The example below tries to be minimalist, but in the real play app, I have an actor receiving events through time and I'd like to pipe those events through SSE. For the time being, there is one actor shot when one hit the url and one SSE channel. Does it make more sense? Cheers Alex On Friday, November 11, 2016 at 1:22:40 PM UTC+1, √ wrote: > > Hi Alexandre, > > perhaps if you describe what you are trying to do, then the readers can > suggest different solutions which might fit the use case? > > On Fri, Nov 11, 2016 at 12:43 PM, Alexandre Masselot < > [email protected] <javascript:>> wrote: > >> >> Thanks √ , >> Your feedback makes real sense. But I'm nonetheless confused about how to >> make it work:) >> >> Alex >> >> On Friday, November 11, 2016 at 11:38:48 AM UTC+1, √ wrote: >>> >>> Because in your actor example you're confusing the materialization of >>> one flow with the returning of another. >>> >>> On Fri, Nov 11, 2016 at 11:29 AM, Alexandre Masselot < >>> [email protected]> wrote: >>> >>>> Hello, >>>> >>>> I'm a bit stuck and seeking for help;) >>>> A play controller should be producing Server Side Events, tying the >>>> Source to an Actor. All this seems pretty basic stuff, but for some >>>> reasons >>>> I cannot make work. >>>> >>>> I pushed a minimalist project >>>> https://github.com/alexmasselot/play-akkastream-sse, but below is the >>>> controller code. >>>> >>>> *Story short:* the first stream works (tick), but the second one does >>>> not (actorFlow). More precisely, pushing messages through the Flow via >>>> Source.actorRef see them printed in the flow but not exposed to the http >>>> stream >>>> >>>> Both can be tested with >>>> >>>> curl -H "Accept: text/event-stream" http://localhost:9000/ticks >>>> curl -H "Accept: text/event-stream" http://localhost:9000/actor-flow >>>> >>>> >>>> >>>> Thanks a lot for the help, >>>> >>>> Alex >>>> >>>> @Singleton >>>> class StreamController @Inject()()(implicit exec: ExecutionContext, >>>> actorSystem: ActorSystem) extends Controller { >>>> implicit val materializer = ActorMaterializer() >>>> >>>> >>>> def tick = Action { >>>> val tickSource = Source.tick(0 millis, 100 millis, "TICK") >>>> Ok.chunked(tickSource via >>>> EventSource.flow).as(ContentTypes.EVENT_STREAM) >>>> } >>>> >>>> def actorFlow = Action { >>>> val source = Source.actorRef[String](10, fail) >>>> .map({ (x) => >>>> //the message go through this stage >>>> println(s"through source '$x'") >>>> x >>>> }) >>>> >>>> val ref = Flow[String] >>>> .to(Sink.ignore) >>>> .runWith( >>>> source >>>> ) >>>> >>>> //send messages. One is now, oth is delayed >>>> ref ! "PAF" >>>> actorSystem.scheduler.scheduleOnce(1000 milliseconds, ref, "delayed >>>> PIF") >>>> >>>> Ok.chunked(source via >>>> EventSource.flow).as(ContentTypes.EVENT_STREAM) >>>> } >>>> } >>>> >>>> >>>> >>>> >>>> -- >>>> >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>> >>>>>>>>>> Check the FAQ: >>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>> >>>>>>>>>> Search the archives: >>>> https://groups.google.com/group/akka-user >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "Akka User List" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at https://groups.google.com/group/akka-user. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> Cheers, >>> √ >>> >> -- >> >>>>>>>>>> Read the docs: http://akka.io/docs/ >> >>>>>>>>>> Check the FAQ: >> http://doc.akka.io/docs/akka/current/additional/faq.html >> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user >> --- >> You received this message because you are subscribed to the Google Groups >> "Akka User List" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/akka-user. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Cheers, > √ > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
