コード例 #1
0
ファイル: Server.java プロジェクト: hlambertOld/ctk
  /**
   * This method first sends a message to the widget specified by handle to get the list of its
   * callbacks, then the server subscribes to each of them. The subscription is added to calls
   *
   * @param handle The widget to subscribe to
   * @param calls The subscription results are added to calls
   */
  private void addWidgetCallbacksSubscription(WidgetHandle handle, Callbacks calls) {
    // Get all callbacks of each widget
    DataObject widgetCalls =
        getWidgetCallbacks(handle.getHostName(), handle.getPort(), handle.getId());
    String error = new Error(widgetCalls).getError();
    if (error != null) {
      if (error.equals(Error.NO_ERROR)) {
        Callbacks cbacks = new Callbacks(widgetCalls);
        // Subscribe to each callback received by the widget
        for (int j = 0; j < cbacks.numCallbacks(); j++) {
          Callback call = cbacks.getCallbackAt(j);
          ClientSideSubscriber css =
              new ClientSideSubscriber(
                  this.getId(),
                  this.getHostName(),
                  this.getPort(),
                  call.getName(),
                  null,
                  handle.getAttributes());
          println("Server in <addWidgetCallbacksSubscription> subscribe to:" + css);
          Error done =
              subscribeTo(
                  (Handler) this, handle.getId(), handle.getHostName(), handle.getPort(), css);
          // The unique id identifying the subscription is in css
          // call.setName(handle.getId()+"_"+call.getName()); // before
          call.setName(css.getSubscriptionId());

          calls.addCallback(call);
        }
      }
    }
  }