in DeviceBridge/Services/SubscriptionScheduler.cs [111:139]
public string ComputeDataSubscriptionStatus(string deviceId, DeviceSubscriptionType subscriptionType, string callbackUrl)
{
// If the callback URL in storage does not match the one currently registered in the client, we can assume that the engine
// is still trying to synchronize this subscription (either it was just created or it's being initialized at startup).
if ((subscriptionType == DeviceSubscriptionType.DesiredProperties && _connectionManager.GetCurrentDesiredPropertyUpdateCallbackId(deviceId) != callbackUrl) ||
(subscriptionType == DeviceSubscriptionType.Methods && _connectionManager.GetCurrentMethodCallbackId(deviceId) != callbackUrl) ||
(subscriptionType == DeviceSubscriptionType.C2DMessages && _connectionManager.GetCurrentMessageCallbackId(deviceId) != callbackUrl))
{
return SubscriptionStatusStarting;
}
var deviceStatus = _connectionManager.GetDeviceStatus(deviceId);
if (deviceStatus?.status == ConnectionStatus.Connected)
{
// Device is connected and callback is registered, so the subscription is running.
return SubscriptionStatusRunning;
}
else if (deviceStatus?.status == ConnectionStatus.Disconnected || deviceStatus?.status == ConnectionStatus.Disabled)
{
// Callbacks match, but the device is disconnected and the SDK won't automatically retry, so the subscription is permanently stopped.
return SubscriptionStatusStopped;
}
else
{
// If the device is not explicitly connected or disconnected, we can assume that the SDK is retrying or a client is being created.
return SubscriptionStatusStarting;
}
}