In this example, is there a way to modify this method
@org.atmosphere.config.service.Message(encoders = {JacksonEncoder.class}, decoders = {JacksonDecoder.class})
public Message onMessage(Message message) throws IOException {
logger.info("{} just send {}", message.getAuthor(), message.getMessage());
return message;
}
so I can get the UUID (available in the AtmosphereResource upon connection) so that I know which connection the message is coming from? I have tried adding an AtmosphereResource parameter, but it doesn't work (no message is received).
Actually, an AtmosphereResource parameter can be added to onMessage. It must be the first parameter. (I tried to add it as the second parameter and it didn't work.)
So the method in the question can be changed to this:
@org.atmosphere.config.service.Message(encoders = {JacksonEncoder.class}, decoders = {JacksonDecoder.class})
public Message onMessage(AtmosphereResource r, Message message) throws IOException {
// TODO: Look up any info associated with the connection using r.uuid().
logger.info("{} just send {}", message.getAuthor(), message.getMessage());
return message;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With