コード例 #1
0
  /*
   * Creates an endpoint with the wildcard adress (::0) and an ephemeral port.
   * The new endpoint gets a client message deliverer and is started.
   * To listen on specific interfaces or ports, set the default endpoint manually.
   * To distinguish different interfaces, one endpoint per interface must be added.
   */
  private synchronized void createDefaultEndpoint() {
    if (default_endpoint != null) return;

    default_endpoint = new CoAPEndpoint();

    try {
      default_endpoint.start();
      LOGGER.log(Level.INFO, "Created implicit default endpoint " + default_endpoint.getAddress());
    } catch (IOException e) {
      LOGGER.log(Level.SEVERE, "Could not create default endpoint", e);
    }
  }
コード例 #2
0
  /**
   * Configures a new default secure endpoint. Any old default endpoint is destroyed.
   *
   * @param endpoint the new default endpoint
   */
  public void setDefaultSecureEndpoint(Endpoint endpoint) {

    if (this.default_secure_endpoint != null) {
      this.default_secure_endpoint.destroy();
    }

    this.default_secure_endpoint = endpoint;

    if (!this.default_secure_endpoint.isStarted()) {
      try {
        default_secure_endpoint.start();
        LOGGER.log(
            Level.INFO, "Started new default secure endpoint " + default_endpoint.getAddress());
      } catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Could not start new default secure endpoint", e);
      }
    }
  }
コード例 #3
0
  /**
   * Configures a new default endpoint. Any old default endpoint is destroyed.
   *
   * @param endpoint the new default endpoint
   */
  public void setDefaultEndpoint(Endpoint endpoint) {

    if (this.default_endpoint != null) {
      this.default_endpoint.destroy();
    }

    LOGGER.config(endpoint.getAddress() + " becomes default endpoint");

    this.default_endpoint = endpoint;

    if (!this.default_endpoint.isStarted()) {
      try {
        default_endpoint.start();
      } catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Could not start new default endpoint", e);
      }
    }
  }