in edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/SubscriptionProcessor.cs [83:131]
async Task ProcessSubscription(string id, Option<ICloudProxy> cloudProxy, DeviceSubscription deviceSubscription, bool addSubscription)
{
switch (deviceSubscription)
{
case DeviceSubscription.C2D:
if (addSubscription)
{
cloudProxy.ForEach(c => c.StartListening());
}
else
{
cloudProxy.ForEach(c => c.StopListening());
}
break;
case DeviceSubscription.DesiredPropertyUpdates:
await cloudProxy.ForEachAsync(c => addSubscription ? c.SetupDesiredPropertyUpdatesAsync() : c.RemoveDesiredPropertyUpdatesAsync());
break;
case DeviceSubscription.Methods:
if (addSubscription)
{
await cloudProxy.ForEachAsync(c => c.SetupCallMethodAsync());
await this.invokeMethodHandler.ProcessInvokeMethodSubscription(id);
}
else
{
await cloudProxy.ForEachAsync(c => c.RemoveCallMethodAsync());
}
break;
case DeviceSubscription.TwinResponse:
// No need for handling addSubscription == true, because the SDK subscribes automatically,
// and because of that the rest of the CloudProxy implementations were built that way later.
if (!addSubscription)
{
await cloudProxy.ForEachAsync(c => c.RemoveTwinResponseAsync());
}
break;
case DeviceSubscription.ModuleMessages:
case DeviceSubscription.Unknown:
// No Action required
break;
}
}