package com.hmsoft.remote.rmi.handler;

import com.hmsoft.remote.rmi.exception.RemotingException;
import com.hmsoft.remote.rmi.transport.NettyChannel;

/**
 * 业务收发handler.
 * @author zq
 *
 */
public interface ChannelHandler {

    /**
     * on channel connected.
     *
     * @param channel channel.
     */
    void connected(NettyChannel channel) throws RemotingException;

    /**
     * on channel disconnected.
     *
     * @param channel channel.
     */
    void disconnected(NettyChannel channel) throws RemotingException;

    /**
     * on message sent.
     *
     * @param channel channel.
     * @param message message.
     */
    void sent(NettyChannel channel, Object message) throws RemotingException;

    /**
     * on message received.
     *
     * @param channel channel.
     * @param message message.
     */
    void received(NettyChannel channel, Object message) throws RemotingException;

    /**
     * on exception caught.
     *
     * @param channel   channel.
     * @param exception exception.
     */
    void caught(NettyChannel channel, Throwable exception) throws RemotingException;
}
