From: Debayan Sutradhar Date: Thu, 29 Apr 2021 18:00:32 +0530 Subject: Added ready method --- Added ready method --- --- 'a/src/main/java/com/stream_pi/server/connection/ClientConnection.java' +++ b/src/main/java/com/stream_pi/server/connection/ClientConnection.java @@ -440,13 +440,18 @@ public class ClientConnection extends Th } } + int totalActions; public void registerProfilesFromClient(Message message) throws StreamPiException { logger.info("Registering profiles ..."); String[] r = message.getStringArrValue(); - for (String profileID : r) { + totalActions = message.getIntValue(); + System.out.println("TTOOOX : "+totalActions); + + for (String profileID : r) + { getProfileDetailsFromClient(profileID); } } @@ -491,6 +496,8 @@ public class ClientConnection extends Th public synchronized void registerActionToProfile(Message message) throws StreamPiException { + totalActions--; + String[] r = message.getStringArrValue(); String profileID = r[0]; @@ -638,6 +645,7 @@ public class ClientConnection extends Th exceptionAndAlertHandler.handleMinorException(new MinorException("action", "Unable to clone")); } + checkIfReady(); return; } } @@ -696,6 +704,16 @@ public class ClientConnection extends Th e.printStackTrace(); exceptionAndAlertHandler.handleMinorException(new MinorException("action", "Unable to clone")); } + + checkIfReady(); + } + + public void checkIfReady() throws SevereException + { + if(totalActions == 0) + { + sendMessage(new Message("ready")); + } } public synchronized void saveActionDetails(String profileID, Action action) throws SevereException @@ -796,11 +814,8 @@ public class ClientConnection extends Th public void onClientScreenDetailsReceived(Message message) { - double width = Double.parseDouble(message.getStringArrValue()[0]); - double height = Double.parseDouble(message.getStringArrValue()[1]); - - getClient().setDisplayWidth(width); - getClient().setDisplayHeight(height); + getClient().setDisplayWidth(message.getDoubleArrValue()[0]); + getClient().setDisplayHeight(message.getDoubleArrValue()[1]); } public void deleteAction(String profileID, String actionID) throws SevereException