mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Change behavior of send()/publish() in LeafNode
Previously publish() was "asynchronously" in that sense that the response of the IQ as *not* awaited, and send() would wait for the responses. It makes no sense to have that functionality this way. Instead we now make publish() to the right thing, i.e., wait for an IQ result, make send() a proxy for publish(), and mark send() deprecated. In the future, there may be a publishAsync() method which returns a Future instance.
This commit is contained in:
parent
c8e7c4804b
commit
c636e72a9d
1 changed files with 22 additions and 44 deletions
|
@ -207,18 +207,16 @@ public class LeafNode extends Node
|
||||||
* This is only acceptable for nodes with {@link ConfigureForm#isPersistItems()}=false
|
* This is only acceptable for nodes with {@link ConfigureForm#isPersistItems()}=false
|
||||||
* and {@link ConfigureForm#isDeliverPayloads()}=false.
|
* and {@link ConfigureForm#isDeliverPayloads()}=false.
|
||||||
*
|
*
|
||||||
* This is an asynchronous call which returns as soon as the
|
|
||||||
* stanza(/packet) has been sent.
|
|
||||||
*
|
|
||||||
* For synchronous calls use {@link #send() send()}.
|
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @throws XMPPErrorException
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @deprecated use {@link #publish()} instead.
|
||||||
*/
|
*/
|
||||||
public void publish() throws NotConnectedException, InterruptedException
|
@Deprecated
|
||||||
|
public void send() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException
|
||||||
{
|
{
|
||||||
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
|
publish();
|
||||||
|
|
||||||
pubSubManager.getConnection().sendStanza(packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,21 +227,18 @@ public class LeafNode extends Node
|
||||||
* Please note that this is not the same as {@link #send()}, which
|
* Please note that this is not the same as {@link #send()}, which
|
||||||
* publishes an event with NO item.
|
* publishes an event with NO item.
|
||||||
*
|
*
|
||||||
* This is an asynchronous call which returns as soon as the
|
|
||||||
* stanza(/packet) has been sent.
|
|
||||||
*
|
|
||||||
* For synchronous calls use {@link #send(Item) send(Item))}.
|
|
||||||
*
|
|
||||||
* @param item - The item being sent
|
* @param item - The item being sent
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @throws XMPPErrorException
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @deprecated use {@link #publish(Item)} instead.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Item> void publish(T item) throws NotConnectedException, InterruptedException
|
@Deprecated
|
||||||
|
public <T extends Item> void send(T item) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException
|
||||||
{
|
{
|
||||||
Collection<T> items = new ArrayList<T>(1);
|
publish(item);
|
||||||
items.add((T)(item == null ? new Item() : item));
|
|
||||||
publish(items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,20 +247,17 @@ public class LeafNode extends Node
|
||||||
* In addition, if {@link ConfigureForm#isPersistItems()}=false, only the last item in the input
|
* In addition, if {@link ConfigureForm#isPersistItems()}=false, only the last item in the input
|
||||||
* list will get stored on the node, assuming it stores the last sent item.
|
* list will get stored on the node, assuming it stores the last sent item.
|
||||||
*
|
*
|
||||||
* This is an asynchronous call which returns as soon as the
|
|
||||||
* stanza(/packet) has been sent.
|
|
||||||
*
|
|
||||||
* For synchronous calls use {@link #send(Collection) send(Collection))}.
|
|
||||||
*
|
|
||||||
* @param items - The collection of items being sent
|
* @param items - The collection of items being sent
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @throws XMPPErrorException
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @deprecated use {@link #publish(Collection)} instead.
|
||||||
*/
|
*/
|
||||||
public <T extends Item> void publish(Collection<T> items) throws NotConnectedException, InterruptedException
|
@Deprecated
|
||||||
|
public <T extends Item> void send(Collection<T> items) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException
|
||||||
{
|
{
|
||||||
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
|
publish(items);
|
||||||
|
|
||||||
pubSubManager.getConnection().sendStanza(packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,17 +267,13 @@ public class LeafNode extends Node
|
||||||
* This is only acceptable for nodes with {@link ConfigureForm#isPersistItems()}=false
|
* This is only acceptable for nodes with {@link ConfigureForm#isPersistItems()}=false
|
||||||
* and {@link ConfigureForm#isDeliverPayloads()}=false.
|
* and {@link ConfigureForm#isDeliverPayloads()}=false.
|
||||||
*
|
*
|
||||||
* This is a synchronous call which will throw an exception
|
|
||||||
* on failure.
|
|
||||||
*
|
|
||||||
* For asynchronous calls, use {@link #publish() publish()}.
|
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
* @throws NoResponseException
|
* @throws NoResponseException
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void send() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
public void publish() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||||
{
|
{
|
||||||
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
|
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
|
||||||
|
|
||||||
|
@ -304,11 +292,6 @@ public class LeafNode extends Node
|
||||||
* Please note that this is not the same as {@link #send()}, which
|
* Please note that this is not the same as {@link #send()}, which
|
||||||
* publishes an event with NO item.
|
* publishes an event with NO item.
|
||||||
*
|
*
|
||||||
* This is a synchronous call which will throw an exception
|
|
||||||
* on failure.
|
|
||||||
*
|
|
||||||
* For asynchronous calls, use {@link #publish(Item) publish(Item)}.
|
|
||||||
*
|
|
||||||
* @param item - The item being sent
|
* @param item - The item being sent
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
* @throws NoResponseException
|
* @throws NoResponseException
|
||||||
|
@ -317,11 +300,11 @@ public class LeafNode extends Node
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Item> void send(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
public <T extends Item> void publish(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||||
{
|
{
|
||||||
Collection<T> items = new ArrayList<T>(1);
|
Collection<T> items = new ArrayList<T>(1);
|
||||||
items.add((item == null ? (T)new Item() : item));
|
items.add((item == null ? (T)new Item() : item));
|
||||||
send(items);
|
publish(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -330,11 +313,6 @@ public class LeafNode extends Node
|
||||||
* In addition, if {@link ConfigureForm#isPersistItems()}=false, only the last item in the input
|
* In addition, if {@link ConfigureForm#isPersistItems()}=false, only the last item in the input
|
||||||
* list will get stored on the node, assuming it stores the last sent item.
|
* list will get stored on the node, assuming it stores the last sent item.
|
||||||
*
|
*
|
||||||
* This is a synchronous call which will throw an exception
|
|
||||||
* on failure.
|
|
||||||
*
|
|
||||||
* For asynchronous calls, use {@link #publish(Collection) publish(Collection))}.
|
|
||||||
*
|
|
||||||
* @param items - The collection of {@link Item} objects being sent
|
* @param items - The collection of {@link Item} objects being sent
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
* @throws NoResponseException
|
* @throws NoResponseException
|
||||||
|
@ -342,7 +320,7 @@ public class LeafNode extends Node
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
public <T extends Item> void publish(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||||
{
|
{
|
||||||
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
|
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue