All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.netty.core.MessageToRunnable Maven / Gradle / Ivy

package com.github.netty.core;

import io.netty.channel.ChannelHandlerContext;

/**
 * Convert the IO message to Runnable
 * Life cycle connection
 *
 * @author wangzihao
 */
@FunctionalInterface
public interface MessageToRunnable {

    /**
     * Create a message handler IO task
     *
     * @param context The connection
     * @param msg     IO messages (attention! : no automatic release, manual release is required)
     * @return Runnable
     */
    Runnable onMessage(ChannelHandlerContext context, Object msg);

    /**
     * Create a error handler IO task
     *
     * @param context   The connection
     * @param throwable Throwable
     * @return Runnable
     */
    default Runnable onError(ChannelHandlerContext context, Throwable throwable) {
        return null;
    }

    /**
     * Create a close handler IO task
     *
     * @param context The connection
     * @return Runnable
     */
    default Runnable onClose(ChannelHandlerContext context) {
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy