Esempio n. 1
0
        public void RequestFeatures(CapsSource source, CapsInfo info)
        {
            if (_pendingRequests.Contains(info))
            {
                return;
            }
            _pendingRequests.Add(info);
            var connection = GetConnection(source.Client);
            var requestId = Guid.NewGuid().ToString("N");
            _requestIdToCapsInfo.Add(requestId, info);

            var iq = new DiscoInfoIq(IqType.get);
            iq.Id = requestId;
            iq.From = connection.MyJID;
            iq.To = new Jid(source.EntityJid);
            if (info.Hash != null && info.Node != null && info.Version != null)
            {
                iq.Query.Node = string.Format("{0}#{1}", info.Node, info.Version);
            }
            connection.Send(iq);
        }
Esempio n. 2
0
        private void ProcessedPresence(CapsSource capsKey, Presence presence)
        {
            var capabilities = presence.Capabilities;
            if (capabilities == null)
            {
                _presentCaps.Remove(capsKey);
                return;
            }
            var version = capabilities.Version;
            var hash = capabilities.Hash;
            var node = capabilities.Node;
            var info = new CapsInfo
            {
                Version = version,
                Hash = hash,
                Node = node,
            };

            if (_presentCaps.ContainsKey(capsKey))
            {
                var prevCaps = _presentCaps[capsKey];
                if (prevCaps == info)
                {
                    return;
                }
            }
            _presentCaps[capsKey] = info;

            if (!_discoveryDataAccess.HasCaps(info))
            {
                _discoveryNetAccess.RequestFeatures(capsKey, info);
            }
        }
Esempio n. 3
0
 private void OnFeatures(CapsInfo version, IList<string> features)
 {
     _discoveryDataAccess.RecordFeatures(version, features);
 }
Esempio n. 4
0
 protected virtual void OnFeaturesReceived(CapsInfo arg1, IList<string> arg2)
 {
     var handler = FeaturesReceived;
     if (handler != null) handler(arg1, arg2);
 }
Esempio n. 5
0
 protected bool Equals(CapsInfo other)
 {
     return string.Equals(Version, other.Version) && string.Equals(Node, other.Node) && string.Equals(Hash, other.Hash);
 }
Esempio n. 6
0
 public void RecordFeatures(CapsInfo info, IList<string> features)
 {
     _dicoveryDA.RecordFeatures(info.Node, info.Hash, info.Version, features);
 }
Esempio n. 7
0
 public bool HasFeature(CapsInfo capsInfo, string uri)
 {
     return _dicoveryDA.HasFeature(capsInfo.Node, capsInfo.Hash, capsInfo.Version, uri);
 }
Esempio n. 8
0
 public bool HasCaps(CapsInfo info)
 {
     return _dicoveryDA.HasCaps(info.Node, info.Hash, info.Version);
 }