Initial framework migration to netty.
[bgpcep.git] / framework / src / main / java / org / opendaylight / protocol / framework / ProtocolSessionInboundHandler.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.framework;
9
10 import io.netty.channel.ChannelHandlerContext;
11 import io.netty.channel.ChannelInboundHandlerAdapter;
12 import io.netty.channel.MessageList;
13
14 final class ProtocolSessionInboundHandler extends ChannelInboundHandlerAdapter {
15
16         private final ProtocolSession session;
17
18         public ProtocolSessionInboundHandler(final ProtocolSession session) {
19                 this.session = session;
20         }
21
22         @Override
23         public void messageReceived(final ChannelHandlerContext ctx, final MessageList<Object> msgs) {
24                 final MessageList<ProtocolMessage> pmsgs = msgs.cast();
25                 for (final ProtocolMessage msg : pmsgs) {
26                         this.session.handleMessage(msg);
27                 }
28         }
29 }