protected _configureEndpoints()

in device/transport/mqtt/src/mqtt.ts [765:804]


  protected _configureEndpoints(credentials: TransportConfig): void {

    if (credentials.moduleId) {
      this._topicTelemetryPublish = endpoint.moduleEventPath(credentials.deviceId, credentials.moduleId).substring(1) + '/';
    } else {
      this._topicTelemetryPublish = endpoint.deviceEventPath(credentials.deviceId).substring(1)  + '/';
    }
    debug('topic publish: ' + this._topicTelemetryPublish);

    // MQTT topics to subscribe to
    this._topics = {};

    this._topics.method = {
      name: '$iothub/methods/POST/#',
      subscribeInProgress: false,
      subscribed: false,
      topicMatchRegex: /^\$iothub\/methods\/POST\/.*$/g,
      handler: this._onDeviceMethod.bind(this)
    };

    if (credentials.moduleId) {
      this._topics.inputMessage = {
        name: endpoint.moduleInputMessagePath(credentials.deviceId, credentials.moduleId).substring(1) + '/#',
        subscribeInProgress: false,
        subscribed: false,
        topicMatchRegex: /^devices\/.*\/modules\/.*\/inputs\/.*\/.*$/g,
        handler: this._onInputMessage.bind(this)
      };
      debug('inputMessage topic subscribe: ' + this._topics.inputMessage.name);
    } else {
      this._topics.message = {
        name: endpoint.deviceMessagePath(credentials.deviceId).substring(1) + '/#',
        subscribeInProgress: false,
        subscribed: false,
        topicMatchRegex: /^devices\/.*\/messages\/devicebound\/.*$/g,
        handler: this._onC2DMessage.bind(this)
      };
      debug('message topic subscribe: ' + this._topics.message.name);
    }
  }