Added support for switch idle state
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / TcpHandler.java
index 7c2041d6a85c4ea5424afe8625b832ab0fcdf306..712f309492b0913e88b320c6f1fd91084720fb73 100644 (file)
@@ -13,6 +13,7 @@ import io.netty.util.concurrent.GenericFutureListener;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 
+import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,7 +45,11 @@ public class TcpHandler implements ServerFacade {
     public static enum COMPONENT_NAMES {
 
         /**
-         * First component in pipeline - detecting TLS connections
+         * Detects switch idle state
+         */
+        IDLE_HANDLER,
+        /**
+         * Detects TLS connections
          */
         TLS_DETECTOR,
         /**
@@ -169,22 +174,6 @@ public class TcpHandler implements ServerFacade {
         return channelInitializer;
     }
     
-    /**
-     * Sets and starts TCPHandler.
-     *
-     * @param args
-     * @throws Exception
-     */
-    public static void main(String[] args) throws Exception {
-        int port;
-        if (args.length > 0) {
-            port = Integer.parseInt(args[0]);
-        } else {
-            port = 6633;
-        }
-        new Thread(new TcpHandler(port)).start();
-    }
-    
     @Override
     public ListenableFuture<Boolean> getIsOnlineFuture() {
         return isOnlineFuture;
@@ -203,5 +192,17 @@ public class TcpHandler implements ServerFacade {
     public String getAddress() {
         return address;
     }
+
+    /**
+     * @param switchConnectionHandler
+     */
+    public void setSwitchConnectionHandler(
+            SwitchConnectionHandler switchConnectionHandler) {
+        channelInitializer.setSwitchConnectionHandler(switchConnectionHandler);
+    }
+    
+    public void setSwitchIdleTimeout(long switchIdleTimeout) {
+        channelInitializer.setSwitchIdleTimeout(switchIdleTimeout);
+    }
     
 }