/// <summary> /// Sends a PubSubSubscribeMessage to subscribe to the given node. /// https://xmpp.org/extensions/xep-0060.html#subscriber-subscribe /// </summary> /// <param name="to">The target e.g. '*****@*****.**' or 'pubsub.example.org'.</param> /// <param name="nodeName">The name of the node, you want to subscribe to.</param> /// <returns>Returns a MessageResponseHelperResult listening for DiscoNodeItemsRequestMessage answers.</returns> public async Task <MessageResponseHelperResult <IQMessage> > requestNodeSubscriptionAsync(string to, string nodeName) { AsyncMessageResponseHelper <IQMessage> helper = new AsyncMessageResponseHelper <IQMessage>(CONNECTION); PubSubSubscribeMessage msg = new PubSubSubscribeMessage(CONNECTION.account.getFullJid(), CONNECTION.account.getBareJid(), to, nodeName); return(await helper.startAsync(msg)); }
/// <summary> /// Sends a PubSubSubscribeMessage to subscribe to the given node. /// </summary> /// <param name="to">The target pubsub server (can be null).</param> /// <param name="nodeName">The name of the node, you want to subscribe to.</param> /// <param name="onMessage">The method that should get executed once the helper receives a new valid message (can be null).</param> /// <param name="onTimeout">The method that should get executed once the helper timeout gets triggered (can be null).</param> /// <returns>Returns a MessageResponseHelper listening for PubSubSubscribeMessage answers.</returns> public MessageResponseHelper <IQMessage> requestNodeSubscription(string to, string nodeName, MessageResponseHelper <IQMessage> .OnMessageHandler onMessage, MessageResponseHelper <IQMessage> .OnTimeoutHandler onTimeout) { MessageResponseHelper <IQMessage> helper = new MessageResponseHelper <IQMessage>(CONNECTION, onMessage, onTimeout); PubSubSubscribeMessage msg = new PubSubSubscribeMessage(CONNECTION.account.getFullJid(), CONNECTION.account.getBareJid(), to, nodeName); helper.start(msg); return(helper); }
/// <summary> /// Sends a PubSubSubscribeMessage for subscribing to the given node. /// </summary> /// <param name="to">The target pubsub server (can be null).</param> /// <param name="nodeName">The name of the node, you want to subscribe to.</param> /// <param name="onMessage">The method that should get executed once the helper receives a new valid message (can be null).</param> /// <param name="onTimeout">The method that should get executed once the helper timeout gets triggered (can be null).</param> /// <returns>Returns a MessageResponseHelper listening for PubSubSubscribeMessage answers.</returns> public MessageResponseHelper <IQMessage> requestNodeSubscription(string to, string nodeName, Func <IQMessage, bool> onMessage, Action onTimeout) { MessageResponseHelper <IQMessage> helper = new MessageResponseHelper <IQMessage>(CLIENT, onMessage, onTimeout); PubSubSubscribeMessage msg = new PubSubSubscribeMessage(CLIENT.getXMPPAccount().getIdDomainAndResource(), CLIENT.getXMPPAccount().getIdAndDomain(), to, nodeName); helper.start(msg); return(helper); }