示例#1
0
        public PushClient(Instagram api, bool tryLoadData = true)
        {
            _instaApi = api ?? throw new ArgumentException("Api can't be null", nameof(api));
            _user     = api.Session;
            _device   = api.Device;

            if (tryLoadData)
            {
                ConnectionData.LoadFromAppSettings();
            }

            // If token is older than 24 hours then discard it
            if ((DateTimeOffset.Now - ConnectionData.FbnsTokenLastUpdated).TotalHours > 24)
            {
                ConnectionData.FbnsToken = "";
            }

            // Build user agent for first time setup
            if (string.IsNullOrEmpty(ConnectionData.UserAgent))
            {
                ConnectionData.UserAgent = FbnsUserAgent.BuildFbUserAgent(_device);
            }

            NetworkInformation.NetworkStatusChanged += async sender =>
            {
                var internetProfile = NetworkInformation.GetInternetConnectionProfile();
                if (internetProfile == null || _loopGroup == null)
                {
                    return;
                }
                await Shutdown();
                await StartFresh();
            };
        }
示例#2
0
        public PushClient(Instagram api, bool tryLoadData = true)
        {
            _instaApi = api ?? throw new ArgumentException("Api can't be null", nameof(api));

            if (tryLoadData)
            {
                ConnectionData.LoadFromAppSettings();
            }

            // If token is older than 24 hours then discard it
            if ((DateTimeOffset.Now - ConnectionData.FbnsTokenLastUpdated).TotalHours > 24)
            {
                ConnectionData.FbnsToken = "";
            }

            // Build user agent for first time setup
            if (string.IsNullOrEmpty(ConnectionData.UserAgent))
            {
                ConnectionData.UserAgent = FbnsUserAgent.BuildFbUserAgent(api.Device);
            }
        }