My application has an Akka-Websocket interface. A web socket consists of an actor-subscriber and an actorβs publisher. The subscriber processes the teams, sending them to the corresponding player. The publisher listens to the stream of events and publishes update information in the stream (and finally to the client). It works well.
My question is: how can the Subscriber send the event back to the stream? For example, to confirm the execution of a received command.
public class WebSocketApp extends HttpApp { private static final Gson gson = new Gson(); @Override public Route createRoute() { return get( path("metrics").route(handleWebSocketMessages(metrics())) ); } private Flow<Message, Message, ?> metrics() { Sink<Message, ActorRef> metricsSink = Sink.actorSubscriber(WebSocketCommandSubscriber.props()); Source<Message, ActorRef> metricsSource = Source.actorPublisher(WebSocketDataPublisherActor.props()) .map((measurementData) -> TextMessage.create(gson.toJson(measurementData))); return Flow.fromSinkAndSource(metricsSink, metricsSource); } }
A good solution would be if the signing actor (the WebSocketCommandSubscriber actor in the above code) could send a message back to the stream, for example sender().tell(...) ...
fs123 source share