src/main/java/in/xnnyygn/xgossip/support/MessageDispatcher.java
/**
     * Remember to register handler before any invoking of post.
     *
     * @param message message
     * @param <T>     payload type
     */
Remember to register handler before any invoking of post.
@param message message
@param      payload type
Remember to register handler before any invoking of post . @param message message @param payload type
@SuppressWarnings("unchecked")
    public <T extends AbstractMessage> void post(RemoteMessage<T> message) {
        Class<? extends AbstractMessage> payloadClass = message.getPayloadClass();
        Handler<T> handler = (Handler<T>) handlerMap.get(payloadClass);
        if (handler == null) {
            logger.warn("no handler for remote message, class {}", payloadClass);
            return;
        }
        handler.handle(message);
    }
@ SuppressWarnings ( "unchecked" ) public < T extends AbstractMessage > void post ( RemoteMessage < T > message ) { Class < ? extends AbstractMessage > payloadClass = message . getPayloadClass ( ) ; Handler < T > handler = ( Handler < T > ) handlerMap . get ( payloadClass ) ; if ( handler == null ) { logger . warn ( "no handler for remote message, class {}" , payloadClass ) ; return ; } handler . handle ( message ) ; }
Remember to register handler before any invoking of post.
Remember to register handler before any invoking of post .