private void notifyOnMessage(MessageListener listener, ServerSession sender, ServerMessage message, Promise<Boolean> promise) { try { listener.onMessage(this, sender, message, Promise.from(promise::succeed, failure -> { _logger.info("Exception reported by listener " + listener, failure); promise.succeed(true); })); } catch (Throwable x) { _logger.info("Exception thrown by listener " + listener, x); promise.succeed(true); } }
/** * <p>Callback invoked when a message is sent.</p> * <p>Implementers can decide to notify the promise with false to signal that the * message should not be further processed, meaning that other session listeners * will not be notified and that the message will be discarded for this session.</p> * * @param session the session that will receive the message * @param sender the session that sent the message * @param message the message sent * @param promise the promise to notify whether the processing of the message should continue */ public default void onMessage(ServerSession session, ServerSession sender, ServerMessage message, Promise<Boolean> promise) { promise.succeed(onMessage(session, sender, message)); }