class WebSocketMessageRouter {

    public void sendMessage(final String sessionId, final SendMessage sendMessage) throws IOException {
        if (!StringUtils.isEmpty(sessionId)) {
            final WebSocketSession session = getSessionOrFail(sessionId);
            sendMessage.send(session);
        } else {
            //The sessionID is not specified so broadcast the message to all connected client sessions.
            sessions.keySet().forEach(itrSessionId -> {
                try {
                    final WebSocketSession session = getSessionOrFail(itrSessionId);
                    sendMessage.send(session);
                } catch (IOException e) {
                    logger.warn("Failed to send message to session {} due to {}", itrSessionId, e, e);
                }
            });
        }
    }

    public  WebSocketMessageRouter(final String endpointId);

}