Move protocol framework from BGPCEP project
[controller.git] / opendaylight / commons / protocol-framework / src / main / java / org / opendaylight / protocol / framework / SessionListener.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 java.util.EventListener;
11
12 /**
13  * Listener that receives session state informations. This interface should be
14  * implemented by a protocol specific abstract class, that is extended by
15  * a final class that implements the methods.
16  */
17 public interface SessionListener<M, S extends ProtocolSession<?>, T extends TerminationReason> extends EventListener {
18     /**
19      * Fired when the session was established successfully.
20      *
21      * @param remoteParams Peer address families which we accepted
22      */
23     void onSessionUp(S session);
24
25     /**
26      * Fired when the session went down because of an IO error. Implementation should take care of closing underlying
27      * session.
28      *
29      * @param session that went down
30      * @param e Exception that was thrown as the cause of session being down
31      */
32     void onSessionDown(S session, Exception e);
33
34     /**
35      * Fired when the session is terminated locally. The session has already been closed and transitioned to IDLE state.
36      * Any outstanding queued messages were not sent. The user should not attempt to make any use of the session.
37      *
38      * @param reason the cause why the session went down
39      */
40     void onSessionTerminated(S session, T reason);
41
42     /**
43      * Fired when a normal protocol message is received.
44      *
45      * @param message Protocol message
46      */
47     void onMessage(S session, M message);
48 }