Ejemplo n.º 1
0
        private async Task CheckDiscoFeaturesBareJidAsync(List <DiscoFeature> features, string discoTarget)
        {
            AddFeaturesForTarget(features, discoTarget);


            if (!CONNECTION.account.pushEnabled)
            {
                CONNECTION.account.CONNECTION_INFO.pushState = PushState.DISABLED;
                Logger.Info("No need to enable push for '" + CONNECTION.account.getBareJid() + "' - disabled");
                return;
            }
            else if (CONNECTION.account.pushNodePublished)
            {
                CONNECTION.account.CONNECTION_INFO.pushState = PushState.ENABLED;
                Logger.Info("No need to enable push for '" + CONNECTION.account.getBareJid() + "' - already enabled");
                return;
            }

            // Check if the server supports 'XEP-0357: Push Notifications':
            bool supportsPush = HasFeature(Consts.XML_XEP_0357_NAMESPACE, discoTarget);

            if (supportsPush)
            {
                await CONNECTION.EnablePushNotificationsAsync();
            }
            else
            {
                CONNECTION.account.CONNECTION_INFO.pushState = PushState.NOT_SUPPORTED;
                Logger.Warn("Unable to enable push notifications for '" + CONNECTION.account.getBareJid() + "' - not supported by the server.");
            }
        }