class ControlWebsocketWorker implements Runnable {

	@Override
	public void run() {
		Thread.currentThread().setName(Constants.LOCAL_API_CONTROL_WEBSOCKET_WORKER);
		LoggingService.logDebug(MODULE_NAME,"Initiating control signals for unacknowledged signals");

		for(Map.Entry<ChannelHandlerContext, ControlSignalSentInfo> contextEntry : WebSocketMap.unackControlSignalsMap.entrySet()){
			ChannelHandlerContext ctx = contextEntry.getKey();
			ControlSignalSentInfo controlSignalSentInfo = contextEntry.getValue();
			int tryCount = controlSignalSentInfo.getSendTryCount();

			long lastSendTime = WebSocketMap.unackControlSignalsMap.get(ctx).getTimeMillis();
			long timeEllapsed = (System.currentTimeMillis() - lastSendTime)/1000;

			if (timeEllapsed > 20) {
				if (tryCount < 10) {
					initiateControlSignal(ctx);
				} else {
					LoggingService.logDebug(MODULE_NAME, " Initiating control signal expires");
					WebSocketMap.unackControlSignalsMap.remove(ctx);
					WebsocketUtil.removeWebsocketContextFromMap(ctx, WebSocketMap.controlWebsocketMap);
					StatusReporter.setLocalApiStatus().setOpenConfigSocketsCount(WebSocketMap.controlWebsocketMap.size());
					return;
				}
			}
		}
		LoggingService.logDebug(MODULE_NAME,"Finished Initiating control signals for unacknowledged signals");
	}

}