Named event stream with Play 2.5 and server sent events

二次信任 提交于 2019-12-12 04:02:54

问题


Default event name/type in server sent event is "message". I am trying to change the event name but it is not working. I am using Play 2.5 and akka streams.

(actorRef,sourcePublisher)=  Source
      .actorRef[T](10, OverflowStrategy.fail)
      .toMat(Sink.asPublisher(true))(Keep.both)
      .run()

backsource = Source.fromPublisher[T](sourcePublisher).named("test1")
Ok.chunked(backsource via EventSource.flow)
      .as(ContentTypes.EVENT_STREAM)

But it is not changing the event name/type. It is still listening to message event rather than test1. Please suggest. Any help is appreciated.


回答1:


I fixed this issue by declaring implicit EventNameExtractor . Below is the code:

implicit def pair[E]: EventNameExtractor[E] = EventNameExtractor[E](p => Some(("test1"))).

It worked.



来源:https://stackoverflow.com/questions/45448191/named-event-stream-with-play-2-5-and-server-sent-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!