/// <summary>
 /// Submits the node configuration.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="form">The configuration form.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> SubmitNodeConfigurationAsync(
     this IClientIqSender iqSender, Jid to, string node, XData form, int timeout, CancellationToken cancellationToken)
 {
     return(await iqSender.SendIqAsync(PubSubBuilder.SubmitNodeConfiguration(to, node, form), timeout, cancellationToken));
 }
 /// <summary>
 /// Remove a contact from the contact list, aka roster
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The jid to remove</param>
 /// <param name="timeout">The timeout</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> RemoveRosterItemAsync(this IClientIqSender iqSender, Jid jid, int timeout, CancellationToken cancellationToken)
 {
     return(await iqSender.SendIqAsync(RosterBuilder.RemoveRosterItem(jid), timeout, cancellationToken));
 }
 /// <summary>
 /// Request the roster (contact list) asynchronous from the server.
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="version"></param>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public static async Task <Iq> RequestRosterAsync(this IClientIqSender iqSender, string version, int timeout)
 {
     return(await RequestRosterAsync(iqSender, version, timeout, CancellationToken.None));
 }
 /// <summary>
 /// Update a Rosteritem
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The jid.</param>
 /// <param name="nickname">The nickname.</param>
 /// <param name="group">The group.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <returns></returns>
 public static async Task <Iq> UpdateRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname, string group, int timeout)
 {
     return(await AddRosterItemAsync(iqSender, jid, nickname, new[] { group }, timeout, CancellationToken.None));
 }
 /// <summary>
 /// Update a Rosteritem
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The jid.</param>
 /// <param name="nickname">The nickname.</param>
 /// <param name="group">The group.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> UpdateRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname, string[] group, int timeout, CancellationToken cancellationToken)
 {
     return(await AddRosterItemAsync(iqSender, jid, nickname, group, timeout, cancellationToken));
 }
 /// <summary>
 /// Add a Rosteritem to the Roster
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The BARE jid of the rosteritem that should be removed</param>
 /// <param name="nickname">Nickname for the RosterItem</param>
 /// <param name="group">An Array of groups when you want to add the Rosteritem to multiple groups</param>
 /// <returns></returns>
 public static async Task <Iq> AddRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname, string[] groups)
 {
     return(await AddRosterItemAsync(iqSender, jid, nickname, groups, DefaultTimeout));
 }
 /// <summary>
 /// Update a Rosteritem
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The jid.</param>
 /// <returns></returns>
 public static async Task <Iq> UpdateRosterItemAsync(this IClientIqSender iqSender, Jid jid)
 {
     return(await AddRosterItemAsync(iqSender, jid, null, new string[] { }));
 }
 /// <summary>
 /// Create an instant node
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">Jid of the PubSub service.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 /// <remarks>
 /// Instant nodes are nodes whose node is is automatically generated by a pubsub service.
 /// </remarks>
 public static async Task <Iq> CreateInstantNodeAsync(
     this IClientIqSender iqSender, Jid to, int timeout, CancellationToken cancellationToken)
 {
     return(await iqSender.SendIqAsync(PubSubBuilder.CreateInstantNode(to), timeout, cancellationToken));
 }
 /// <summary>
 /// Retrieve Subscriptions List
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <returns></returns>
 public static async Task <Iq> RequestSubscriptionsListAsync(this IClientIqSender iqSender, Jid to, string node)
 {
     return(await RequestSubscriptionsListAsync(iqSender, to, node, DefaultTimeout, CancellationToken.None));
 }
 /// <summary>
 /// Unsubscribes from a node.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="subId">The sub id.</param>
 /// <param name="jid">The jid.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> UnsubscribeAsync(
     this IClientIqSender iqSender, Jid to, string node, string subId, Jid jid, int timeout, CancellationToken cancellationToken)
 {
     return(await iqSender.SendIqAsync(PubSubBuilder.Unsubscribe(to, node, subId, jid), timeout, cancellationToken));
 }
 /// <summary>
 /// Request all current subscriptions.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <returns></returns>
 public static async Task <Iq> RequestAllSubscriptionsAsync(this IClientIqSender iqSender, Jid to, int timeout)
 {
     return(await RequestAllSubscriptionsAsync(iqSender, to, timeout, CancellationToken.None));
 }
 /// <summary>
 /// Unsubscribes from a node.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="subId">The sub id.</param>
 /// <param name="jid">The jid.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <returns></returns>
 public static async Task <Iq> UnsubscribeAsync(this IClientIqSender iqSender, Jid to, string node, string subId, Jid jid, int timeout)
 {
     return(await UnsubscribeAsync(iqSender, to, node, subId, jid, timeout, CancellationToken.None));
 }
 /// <summary>
 /// Create an instant node
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">Jid of the PubSub service.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <returns></returns>
 /// <remarks>
 /// Instant nodes are nodes whose node is is automatically generated by a pubsub service.
 /// </remarks>
 public static async Task <Iq> CreateInstantNodeAsync(this IClientIqSender iqSender, Jid to, int timeout)
 {
     return(await CreateInstantNodeAsync(iqSender, to, timeout, CancellationToken.None));
 }
 /// <summary>
 /// Unsubscribes from a node.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="jid">The jid.</param>
 /// <returns></returns>
 public static async Task <Iq> UnsubscribeAsync(this IClientIqSender iqSender, Jid to, string node, Jid jid)
 {
     return(await UnsubscribeAsync(iqSender, to, node, null, jid, DefaultTimeout, CancellationToken.None));
 }
 /// <summary>
 /// Add a Rosteritem to the Roster
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The BARE jid of the rosteritem that should be removed</param>
 /// <param name="nickname">Nickname for the RosterItem</param>
 /// <param name="group">The group to which the roteritem should be added</param>
 /// <returns></returns>
 public static async Task <Iq> AddRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname, string group)
 {
     return(await AddRosterItemAsync(iqSender, jid, nickname, !String.IsNullOrEmpty(group)?new[] { group } : new string[] { }));
 }
 /// <summary>
 /// Retrieve Subscriptions List
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> RequestSubscriptionsListAsync(
     this IClientIqSender iqSender, Jid to, string node, int timeout, CancellationToken cancellationToken)
 {
     return(await iqSender.SendIqAsync(PubSubBuilder.RequestSubscriptionsList(to, node), timeout, cancellationToken));
 }
 /// <summary>
 /// Add a Rosteritem to the Roster
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The BARE jid of the rosteritem that should be removed</param>
 /// <param name="nickname">Nickname for the RosterItem</param>
 /// <param name="group">The group to which the roteritem should be added</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> AddRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname, string group, int timeout, CancellationToken cancellationToken)
 {
     return(await AddRosterItemAsync(iqSender, jid, nickname, !String.IsNullOrEmpty(group)?new[] { group } : new string[] { }, timeout, cancellationToken));
 }
 /// <summary>
 /// Purges all node item.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">Jid of the pubsub service for this request</param>
 /// <param name="node">The node.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <returns></returns>
 /// <remarks>
 /// If a service persists published items, a node owner may want to purge
 /// the node of all published items (thus removing all items from the
 /// persistent store, with the exception of the last published item,
 /// which MAY be cached). It is OPTIONAL for a service to implement this
 /// feature.
 /// </remarks>
 public static async Task <Iq> PurgeNodeAsync(this IClientIqSender iqSender, Jid to, string node, int timeout)
 {
     return(await PurgeNodeAsync(iqSender, to, node, timeout, CancellationToken.None));
 }
        /// <summary>
        /// Add a Rosteritem to the Roster
        /// </summary>
        /// <param name="iqSender"><see cref="IClientIqSender"/></param>
        /// <param name="jid">The BARE jid of the rosteritem that should be removed</param>
        /// <param name="nickname">Nickname for the RosterItem</param>
        /// <param name="group">An Array of groups when you want to add the Rosteritem to multiple groups</param>
        /// <param name="timeout">The timeout in milliseconds.</param>
        /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
        /// <returns></returns>
        public static async Task <Iq> AddRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname, string[] groups, int timeout, CancellationToken cancellationToken)
        {
            var riq = RosterBuilder.AddRosterItem(jid, nickname, groups);

            return(await iqSender.SendIqAsync(riq, timeout, cancellationToken));
        }
 /// <summary>
 /// Creates a new node.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <returns></returns>
 public static async Task <Iq> CreateNodeAsync(this IClientIqSender iqSender, Jid to, string node)
 {
     return(await CreateNodeAsync(iqSender, to, node, null));
 }
 /// <summary>
 /// Update a Rosteritem
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The jid.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> UpdateRosterItemAsync(this IClientIqSender iqSender, Jid jid, int timeout, CancellationToken cancellationToken)
 {
     return(await AddRosterItemAsync(iqSender, jid, null, new string[] { }, timeout, cancellationToken));
 }
 /// <summary>
 /// Purges all node item.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">Jid of the pubsub service for this request</param>
 /// <param name="node">The node.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 /// <remarks>
 /// If a service persists published items, a node owner may want to purge
 /// the node of all published items (thus removing all items from the
 /// persistent store, with the exception of the last published item,
 /// which MAY be cached). It is OPTIONAL for a service to implement this
 /// feature.
 /// </remarks>
 public static async Task <Iq> PurgeNodeAsync(
     this IClientIqSender iqSender, Jid to, string node, int timeout, CancellationToken cancellationToken)
 {
     return(await iqSender.SendIqAsync(PubSubBuilder.PurgeNode(to, node), timeout, cancellationToken));
 }
 /// <summary>
 /// Update a Rosteritem
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The jid.</param>
 /// <param name="nickname">The nickname.</param>
 /// <param name="group">The group.</param>
 /// <returns></returns>
 public static async Task <Iq> UpdateRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname, string[] group)
 {
     return(await AddRosterItemAsync(iqSender, jid, nickname, group));
 }
 /// <summary>
 /// Request an item
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">Jid of the pubsub service for this request</param>
 /// <param name="node">The node.</param>
 /// <param name="id">The id</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <returns></returns>
 public static async Task <Iq> RequestItemAsync(
     this IClientIqSender iqSender, Jid to, string node, string id, int timeout)
 {
     return(await RequestItemAsync(iqSender, to, node, id, timeout, CancellationToken.None));
 }
 /// <summary>
 /// Remove a contact from the contact list, aka roster
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The jid to remove</param>
 /// <returns></returns>
 public static async Task <Iq> RemoveRosterItemAsync(this IClientIqSender iqSender, Jid jid)
 {
     return(await RemoveRosterItemAsync(iqSender, jid, DefaultTimeout));
 }
 /// <summary>
 /// Request the roster (contact list) asynchronous from the server.
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="version"></param>
 /// <param name="timeout"></param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> RequestRosterAsync(this IClientIqSender iqSender, string version, int timeout, CancellationToken cancellationToken)
 {
     return(await iqSender.SendIqAsync(RosterBuilder.RequestRoster(version), timeout, cancellationToken));
 }
 /// <summary>
 /// Request the roster (contact list) asynchronous from the server.
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="timeout"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public static async Task <Iq> RequestRosterAsync(this IClientIqSender iqSender, int timeout, CancellationToken cancellationToken)
 {
     return(await RequestRosterAsync(iqSender, null, DefaultTimeout, CancellationToken.None));
 }
 /// <summary>
 /// Add a Rosteritem to the Roster
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="jid">The BARE jid of the rosteritem that should be removed</param>
 /// <param name="nickname">Nickname for the RosterItem</param>
 /// <returns></returns>
 public static async Task <Iq> AddRosterItemAsync(this IClientIqSender iqSender, Jid jid, string nickname)
 {
     return(await AddRosterItemAsync(iqSender, jid, nickname, new string[] { }));
 }
 /// <summary>
 /// Request the roster (contact list) asynchronous from the server.
 /// </summary>
 /// <param name="iqSender"><see cref="IClientIqSender"/></param>
 /// <param name="version"></param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> RequestRosterAsync(this IClientIqSender iqSender, string version, CancellationToken cancellationToken)
 {
     return(await RequestRosterAsync(iqSender, version, DefaultTimeout, cancellationToken));
 }
 /// <summary>
 /// Submits the node configuration.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="form">The configuration form.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <returns></returns>
 public static async Task <Iq> SubmitNodeConfigurationAsync(this IClientIqSender iqSender, Jid to, string node, XData form, int timeout)
 {
     return(await SubmitNodeConfigurationAsync(iqSender, to, node, form, timeout, CancellationToken.None));
 }