If we have already a sensor connection defined, we skip to the subscription of sensor data directly. There's no need to perform an actual search:
if (!string.IsNullOrEmpty(this.sensorJid)) this.SubscribeToSensorData();
If, on the other hand, a sensor connection is not defined, or if an actuator connection is not defined, we need to perform a search. We want to find appropriate devices near where the controller is. We do this by preparing the search and aggregating search operators (defined in the Waher.Networking.XMPP.Provisioning.SearchOperators namespace) corresponding to the location-based metadata tags we are using in our registration:
if (string.IsNullOrEmpty(this.sensorJid) || string.IsNullOrEmpty(this.actuatorJid)) ...