0

服务器发送的事件中的默认事件名称/类型为“消息”。我正在尝试更改事件名称,但它不起作用。我使用Play 2.5和akka流。以Play 2.5命名的事件流和服务器发送的事件

(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) 

但它不改变事件名称/类型。它仍在收听消息事件而不是test1。请建议。任何帮助表示赞赏。

回答

0

我通过声明隐式的EventNameExtractor解决了这个问题。以下是代码:

隐式def对[E]:EventNameExtractor [E] = EventNameExtractor [E](P => Some((“test1”)))。

它工作。