mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUACAMOLE-504: Reimplement closeConnection() with int parameters.
This commit is contained in:
		| @@ -73,14 +73,12 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint { | ||||
|      * @param guac_status The status to send. | ||||
|      * @param webSocketCode The numeric WebSocket status to send. | ||||
|      */ | ||||
|     private void closeConnection(Session session, GuacamoleStatus guac_status, | ||||
|             Integer webSocketCode) { | ||||
|     private void closeConnection(Session session, int guacamoleStatusCode, | ||||
|             int webSocketCode) { | ||||
|  | ||||
|         try { | ||||
|             if (webSocketCode == null) | ||||
|                 webSocketCode = guac_status.getWebSocketCode(); | ||||
|             CloseCode code = CloseReason.CloseCodes.getCloseCode(webSocketCode); | ||||
|             String message = Integer.toString(guac_status.getGuacamoleStatusCode()); | ||||
|             String message = Integer.toString(guacamoleStatusCode); | ||||
|             session.close(new CloseReason(code, message)); | ||||
|         } | ||||
|         catch (IOException e) { | ||||
| @@ -113,7 +111,8 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint { | ||||
|             // Get tunnel | ||||
|             tunnel = createTunnel(session, config); | ||||
|             if (tunnel == null) { | ||||
|                 closeConnection(session, GuacamoleStatus.RESOURCE_NOT_FOUND, null); | ||||
|                 closeConnection(session, GuacamoleStatus.RESOURCE_NOT_FOUND.getGuacamoleStatusCode(), | ||||
|                         GuacamoleStatus.RESOURCE_NOT_FOUND.getWebSocketCode()); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
| @@ -121,7 +120,7 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint { | ||||
|         catch (GuacamoleException e) { | ||||
|             logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage()); | ||||
|             logger.debug("Error connecting WebSocket tunnel.", e); | ||||
|             closeConnection(session, e.getStatus(), e.getWebSocketCode()); | ||||
|             closeConnection(session, e.getStatus().getGuacamoleStatusCode(), e.getWebSocketCode()); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| @@ -175,7 +174,8 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint { | ||||
|                         } | ||||
|  | ||||
|                         // No more data | ||||
|                         closeConnection(session, GuacamoleStatus.SUCCESS, null); | ||||
|                         closeConnection(session, GuacamoleStatus.SUCCESS.getGuacamoleStatusCode(), | ||||
|                                 GuacamoleStatus.SUCCESS.getWebSocketCode()); | ||||
|  | ||||
|                     } | ||||
|  | ||||
| @@ -185,22 +185,24 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint { | ||||
|                     catch (GuacamoleClientException e) { | ||||
|                         logger.info("WebSocket connection terminated: {}", e.getMessage()); | ||||
|                         logger.debug("WebSocket connection terminated due to client error.", e); | ||||
|                         closeConnection(session, e.getStatus(), e.getWebSocketCode()); | ||||
|                         closeConnection(session, e.getStatus().getGuacamoleStatusCode(), e.getWebSocketCode()); | ||||
|                     } | ||||
|                     catch (GuacamoleConnectionClosedException e) { | ||||
|                         logger.debug("Connection to guacd closed.", e); | ||||
|                         closeConnection(session, GuacamoleStatus.SUCCESS, null); | ||||
|                         closeConnection(session, GuacamoleStatus.SUCCESS.getGuacamoleStatusCode(), | ||||
|                                 GuacamoleStatus.SUCCESS.getWebSocketCode()); | ||||
|                     } | ||||
|                     catch (GuacamoleException e) { | ||||
|                         logger.error("Connection to guacd terminated abnormally: {}", e.getMessage()); | ||||
|                         logger.debug("Internal error during connection to guacd.", e); | ||||
|                         closeConnection(session, e.getStatus(), e.getWebSocketCode()); | ||||
|                         closeConnection(session, e.getStatus().getGuacamoleStatusCode(), e.getWebSocketCode()); | ||||
|                     } | ||||
|  | ||||
|                 } | ||||
|                 catch (IOException e) { | ||||
|                     logger.debug("I/O error prevents further reads.", e); | ||||
|                     closeConnection(session, GuacamoleStatus.SERVER_ERROR, null); | ||||
|                     closeConnection(session, GuacamoleStatus.SERVER_ERROR.getGuacamoleStatusCode(), | ||||
|                             GuacamoleStatus.SERVER_ERROR.getWebSocketCode()); | ||||
|                 } | ||||
|  | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user