proposals variable is updated from database whenever an update comes
it then sends data as raw text toString() to the browser using a foreach of proposals
@RequestMapping(path = "/", method = RequestMethod.POST)
@KafkaListener(topics = "updates")
public String showMessage(String data) {
proposals = service.getAllProposal();
synchronized (this.sseEmitters) {
for (SseEmitter sseEmitter : this.sseEmitters) {
proposals.parallelStream().forEach(c -> {
try {
sseEmitter.send(c.toString());
} catch (Exception e) {
logger.error("Se ha cerrado el navegador");
}
});
}
}
//creo que aqui se puede mandar un modelo y data como un atributo del modelo igual que la anterior vez
return data;
}
We sould need to send model to the view and send the emitter data as an attribute of the model, not the data itself as raw text
@guille I've just changed this. If you check index.html you can see how it gets events from different urls, and parse them as an element in the dom using EventSource in Githubissues.
Githubissues is a development platform for aggregating issues.
proposals variable is updated from database whenever an update comes it then sends data as raw text toString() to the browser using a foreach of proposals
We sould need to send model to the view and send the emitter data as an attribute of the model, not the data itself as raw text