/**
   * a message was received from the server. Here we dispatch the message to the client's thread
   * pool to minimize the time it takes to process other messages.
   *
   * @param ctx The channel the message was received from
   * @param msg The message
   */
  @Override
  protected void channelRead0(ChannelHandlerContext ctx, Request msg) throws Exception {
    System.out.println("Received Msg@@@@@@@");
    answer.add(msg);
    for (String id : listeners.keySet()) {
      CommunicationListener cl = listeners.get(id);

      // TODO this may need to be delegated to a thread pool to allow
      // async processing of replies
      cl.onMessage(msg);
    }
  }
  /**
   * Notification registration. Classes/Applications receiving information will register their
   * interest in receiving content.
   *
   * <p>Note: Notification is serial, FIFO like. If multiple listeners are present, the data
   * (message) is passed to the listener as a mutable object.
   *
   * @param listener
   */
  public void addListener(CommunicationListener listener) {
    if (listener == null) return;

    listeners.putIfAbsent(listener.getListenerID(), listener);
  }