private void DiscoverCapabilities() { IQ requestIq = new IQ(); ServiceQuery request = new ServiceQuery(); request.Node = this.Capabilities.DiscoveryInfoNode; requestIq.From = this.session.UserId; requestIq.ID = XmppIdentifierGenerator.Generate(); requestIq.To = this.ResourceId; requestIq.Type = IQType.Get; requestIq.Items.Add(request); this.pendingMessages.Add(requestIq.ID); this.session.Send(requestIq); }
protected override void OnServiceDiscoveryMessage(IQ message) { // Answers to Entity Capabilities and service discovery info requests if (message.Type == IQType.Get) { if (message.Items[0] is ServiceQuery) { ServiceQuery query = (ServiceQuery)message.Items[0]; ServiceQuery response = new ServiceQuery() { Node = ((!String.IsNullOrEmpty(query.Node)) ? this.DiscoveryInfoNode : null) }; IQ responseIq = new IQ { From = this.session.UserId, ID = message.ID, To = message.From, Type = IQType.Result }; foreach (XmppServiceIdentity identity in this.Identities) { ServiceIdentity supportedIdentity = new ServiceIdentity { Name = identity.Name, Category = identity.Category.ToString().ToLower(), Type = identity.Type }; response.Identities.Add(supportedIdentity); } foreach (XmppServiceFeature supportedFeature in this.Features) { ServiceFeature feature = new ServiceFeature { Name = supportedFeature.Name }; response.Features.Add(feature); } responseIq.Items.Add(response); this.session.Send(responseIq); //// Error response //IQ errorIq = new IQ(); //ServiceQuery response = new ServiceQuery(); //Error error = new Error(); //errorIq.From = this.session.UserId.ToString(); //errorIq.ID = e.QueryResult.ID; //errorIq.To = e.QueryResult.From; //errorIq.Type = IQType.Error; //errorIq.Error = error; //response.Node = query.Node; //error.Type = ErrorType.Cancel; //error.ItemNotFound = ""; //errorIq.Items.Add(response); //this.session.Send(errorIq); } } }