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 java.io.IOException;
11 import java.util.List;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 import com.google.common.collect.Lists;
18 public class Session implements ProtocolSession {
20 private static final Logger logger = LoggerFactory.getLogger(Session.class);
22 public final List<ProtocolMessage> msgs = Lists.newArrayList();
24 private final ProtocolMessageFactory pmf = new MessageFactory();
26 private final SessionParent parent;
28 public boolean up = false;
30 private final int maxMsgSize;
32 public Session(final SessionParent parent, final int maxMsgSize) {
34 this.maxMsgSize = maxMsgSize;
38 public void close() throws IOException {
43 public void startSession() {
44 // this.pos.putMessage(new Message("hello"), this.pmf);
48 public void handleMessage(final ProtocolMessage msg) {
49 logger.debug("Message received: {}", ((Message) msg).getMessage());
52 logger.debug(this.msgs.size() + "");
56 public void handleMalformedMessage(final DeserializerException e) {
57 logger.debug("Malformed message: {}", e.getMessage(), e);
61 public void handleMalformedMessage(final DocumentedException e) {
62 logger.debug("Malformed message: {}", e.getMessage(), e);
66 public void endOfInput() {
67 logger.debug("End of input reported.");
71 public ProtocolMessageFactory getMessageFactory() {
76 public void onConnectionFailed(final IOException e) {
77 logger.debug("Connection failed: {}", e.getMessage(), e);
81 public int maximumMessageSize() {
82 return this.maxMsgSize;