BUG-58: refactor to take advantage of netty
[bgpcep.git] / framework / src / main / java / org / opendaylight / protocol / framework / SessionListener.java
index 5f52af725563b4d7e20ed7ef460f42dafece5b95..805c769a7e3b8758d11e3ba7e01597da87e7c088 100644 (file)
@@ -10,10 +10,39 @@ package org.opendaylight.protocol.framework;
 import java.util.EventListener;
 
 /**
- *     Listener that receives session state informations. This interface should be
- *  implemented by a protocol specific abstract class, that is extended by
- *  a final class that implements the methods.
+ * Listener that receives session state informations. This interface should be
+ * implemented by a protocol specific abstract class, that is extended by
+ * a final class that implements the methods.
  */
-public interface SessionListener extends EventListener {
+public interface SessionListener<M extends ProtocolMessage, S extends ProtocolSession<?>, T extends TerminationReason> extends EventListener {
+       /**
+        * Fired when the session was established successfully.
+        * 
+        * @param remoteParams Peer address families which we accepted
+        */
+       public void onSessionUp(S session);
 
+       /**
+        * Fired when the session went down because of an IO error. Implementation should take care of closing underlying
+        * session.
+        * 
+        * @param session that went down
+        * @param e Exception that was thrown as the cause of session being down
+        */
+       public void onSessionDown(S session, Exception e);
+
+       /**
+        * Fired when the session is terminated locally. The session has already been closed and transitioned to IDLE state.
+        * Any outstanding queued messages were not sent. The user should not attempt to make any use of the session.
+        * 
+        * @param reason the cause why the session went down
+        */
+       public void onSessionTerminated(S session, T reason);
+
+       /**
+        * Fired when a normal protocol message is received.
+        * 
+        * @param message Protocol message
+        */
+       public void onMessage(S session, M message);
 }