1 /*
2 * Copyright 2012 The Netty Project
3 *
4 * The Netty Project licenses this file to you under the Apache License,
5 * version 2.0 (the "License"); you may not use this file except in compliance
6 * with the License. You may obtain a copy of the License at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16 package io.netty.channel;
17
18 /**
19 * {@link ChannelHandler} which adds callbacks for state changes. This allows the user
20 * to hook in to state changes easily.
21 */
22 public interface ChannelInboundHandler extends ChannelHandler {
23
24 /**
25 * The {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link EventLoop}
26 */
27 void channelRegistered(ChannelHandlerContext ctx) throws Exception;
28
29 /**
30 * The {@link Channel} of the {@link ChannelHandlerContext} was unregistered from its {@link EventLoop}
31 */
32 void channelUnregistered(ChannelHandlerContext ctx) throws Exception;
33
34 /**
35 * The {@link Channel} of the {@link ChannelHandlerContext} is now active
36 */
37 void channelActive(ChannelHandlerContext ctx) throws Exception;
38
39 /**
40 * The {@link Channel} of the {@link ChannelHandlerContext} was registered is now inactive and reached its
41 * end of lifetime.
42 */
43 void channelInactive(ChannelHandlerContext ctx) throws Exception;
44
45 /**
46 * Invoked when the current {@link Channel} has read a message from the peer.
47 */
48 void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception;
49
50 /**
51 * Invoked when the last message read by the current read operation has been consumed by
52 * {@link #channelRead(ChannelHandlerContext, Object)}. If {@link ChannelOption#AUTO_READ} is off, no further
53 * attempt to read an inbound data from the current {@link Channel} will be made until
54 * {@link ChannelHandlerContext#read()} is called.
55 */
56 void channelReadComplete(ChannelHandlerContext ctx) throws Exception;
57
58 /**
59 * Gets called if an user event was triggered.
60 */
61 void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception;
62
63 /**
64 * Gets called once the writable state of a {@link Channel} changed. You can check the state with
65 * {@link Channel#isWritable()}.
66 */
67 void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception;
68
69 /**
70 * Gets called if a {@link Throwable} was thrown.
71 */
72 @Override
73 @SuppressWarnings("deprecation")
74 void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception;
75 }