-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for connectivity change in .NET Standard #59
Comments
As far as we're aware, there is no API in .NET Standard 2.0 for finding out about the host machine's network connectivity state. That is an issue with the runtime— Microsoft just did not provide a portable mechanism for getting that information. We could have addressed this by providing builds for other platform-specific target frameworks, such as .NET Framework for Windows, or Xamarin for MacOS, but this had enough implementation difficulties (the SDK is currently built with Future versions of this SDK will likely have a target framework of .NET 6.0, and it may be that that runtime does have a portable API for detecting connectivity state— we haven't looked into it yet. But at present it's not an option. |
As for your other suggestion of a And, regarding your third option, I can't think what you could accomplish by implementing your own As far as I know, the only difference between the SDK suspending network activity because |
Thanks for your input. I've tried subscribing to My expectation would be if I call |
Hmm... that may be a bug. My understanding of this logic was that it would fire for any transition in the state, regardless of what caused it. I'll try to reproduce this. However, on a different point: in this SDK, I'm not sure there is much value in calling |
So what you're saying is if I call I would want a clear image on from where did the SDK provide me a flag. If I setup persistence with .Persistence(Components.Persistence()) in .NET Standard that will be IsolatedStorage. From this point can you confirm this is how the SDK evaluates flags? For example by calling
|
That's right. Any time it is in a state of either "I'm aware that the network isn't available, because this is a phone and the phone OS has told me the network isn't available", or "the application has told me to stay offline by calling SetOffline(true)", or both, it will not try to connect or reconnect. Any time it transitions to a state where neither of those things is true, it tries to connect, just as it would if you had started it in such a state. And any successful connection results in it getting and storing the last data. That's what the API documentation means when it says this:
And in that case, SetOffline does not return (unless it times out), and SetOfflineAsync's task does not complete, until the connection has been made and the new data has been obtained, so you know that any calls to the Variation methods after that point will be using the new data. |
No, that's not correct. Here is what happens:
|
So in the end all I need to do is just to call SetOffline(false) and I'll get up to date data all the time. Thanks for the explanation, this clears up a few things! |
That's how it should work, yes. I'll still look into the possible issue of the |
Any updates on the StatusChanged event? I'm getting very inconsistent behaviour. The other issue I have is that LdClient.Init(...) will create the ldclient instance and call Start(...) on it, which will trigger the StateChanged event if it's successful, but I can't subscribe to the event only after Init has finished and I have an actual object, so initially I won't get the Valid state change. |
@raksanyi I'm sorry that I haven't looked into it yet. I had not made it a high priority because it sounded like you did not actually need to rely on the StatusChanged event after all to do what you wanted to do, but maybe I misread your comments. |
I also don't quite understand why you need to see the initial Valid state change. I mean, if you've just initialized a client, you can look at |
|
Currently in .NET Standard there's no way to listen on connectivity changes as described in Connectivity.netstandard.cs.
SetOffline is already part of the public API. What I would like to have is either:
The "SetOnline" solution seems to be the easiest change, but I don't know if it would break any other behaviour.
Would it be possible to implement a solution for .net standard? If not, are there any ways to force the LD client to go online whenever there's a network change?
The text was updated successfully, but these errors were encountered: