DaanHoogland commented on a change in pull request #4300:
URL: https://github.com/apache/cloudstack/pull/4300#discussion_r585550677



##########
File path: 
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVncClient.java
##########
@@ -121,22 +126,33 @@ public void run() {
                         s_logger.error("Unexpected exception", e);
                     }
 
-                    String ver = client.handshake();
-                    
session.getRemote().sendBytes(ByteBuffer.wrap(ver.getBytes(), 0, ver.length()));
+                    String ver;
+                    byte[] b;
+                    if (!client.isVncOverWebSocketConnection()) {
+                        ver = client.handshake();
+                        
session.getRemote().sendBytes(ByteBuffer.wrap(ver.getBytes(), 0, ver.length()));
 
-                    byte[] b = client.authenticate(getClientHostPassword());
-                    session.getRemote().sendBytes(ByteBuffer.wrap(b, 0, 4));
+                        b = client.authenticate(getClientHostPassword());
+                        session.getRemote().sendBytes(ByteBuffer.wrap(b, 0, 
4));
+                    }
 
                     int readBytes;
                     while (connectionAlive) {
-                        b = new byte[100];
-                        readBytes = client.read(b);
-                        if (readBytes == -1) {
-                            break;
-                        }
-                        if (readBytes > 0) {
-                            session.getRemote().sendBytes(ByteBuffer.wrap(b, 
0, readBytes));
-                            updateFrontEndActivityTime();
+                        if (client.isVncOverWebSocketConnection()) {
+                            if (client.isVncOverWebSocketConnectionOpen()) {
+                                updateFrontEndActivityTime();
+                            }
+                            connectionAlive = 
client.isVncOverWebSocketConnectionAlive();
+                        } else {
+                            b = new byte[100];
+                            readBytes = client.read(b);
+                            if (readBytes == -1) {
+                                break;
+                            }
+                            if (readBytes > 0) {
+                                
session.getRemote().sendBytes(ByteBuffer.wrap(b, 0, readBytes));
+                                updateFrontEndActivityTime();
+                            }

Review comment:
       could you disect `initlient()` into multiple methods, it is sneakily 
growing too complex.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to