2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.framework;
10 import io.netty.channel.ChannelHandlerContext;
11 import io.netty.channel.SimpleChannelInboundHandler;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 final class ProtocolSessionInboundHandler extends SimpleChannelInboundHandler<ProtocolMessage> {
18 private final static Logger logger = LoggerFactory.getLogger(ProtocolSessionInboundHandler.class);
20 private final ProtocolSession session;
22 public ProtocolSessionInboundHandler(final ProtocolSession session) {
23 this.session = session;
27 public void channelActive(final ChannelHandlerContext ctx) throws Exception {
28 logger.debug("Channel active.");
29 this.session.startSession();
33 public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
34 logger.debug("Channel inactive.");
35 this.session.endOfInput();
39 protected void channelRead0(final ChannelHandlerContext ctx, final ProtocolMessage msg) throws Exception {
40 logger.debug("Message was received: {}", msg);
41 this.session.handleMessage(msg);
44 public ProtocolSession getSession() {