diff --git a/source/org/jivesoftware/smack/PacketCollector.java b/source/org/jivesoftware/smack/PacketCollector.java index af2737eac..4aae9d9c2 100644 --- a/source/org/jivesoftware/smack/PacketCollector.java +++ b/source/org/jivesoftware/smack/PacketCollector.java @@ -123,7 +123,7 @@ public class PacketCollector { } /** - * Polls to see if a result is currently available and returns it, or + * Polls to see if a packet is currently available and returns it, or * immediately returns null if no packets are currently in the * result queue. * @@ -139,6 +139,12 @@ public class PacketCollector { } } + /** + * Returns the next available packet. The method call will block (not return) + * until a packet is available. + * + * @return the next available packet. + */ public synchronized Packet nextResult() { // Wait indefinitely until there is a result to return. while (resultQueue.isEmpty()) { @@ -150,6 +156,14 @@ public class PacketCollector { return (Packet)resultQueue.removeLast(); } + /** + * Returns the next available packet. The method call will block (not return) + * until a packet is available or the timeout has elapased. If the + * timeout elapses without a result, null will be returned. + * + * @param timeout the amount of time to wait for the next packet (in milleseconds). + * @return the next available packet. + */ public synchronized Packet nextResult(long timeout) { // Wait up to the specified amount of time for a result. if (resultQueue.isEmpty()) { diff --git a/source/org/jivesoftware/smack/packet/Presence.java b/source/org/jivesoftware/smack/packet/Presence.java index dea1cc793..97cd01172 100644 --- a/source/org/jivesoftware/smack/packet/Presence.java +++ b/source/org/jivesoftware/smack/packet/Presence.java @@ -55,8 +55,22 @@ package org.jivesoftware.smack.packet; import org.jivesoftware.smack.*; /** - * Represents XMPP presence packets. Every presence packet has a type, while a - * number of attributes are optional: + * Represents XMPP presence packets. Every presence packet has a type, which is one of + * the following values: + *
+ * + * A number of attributes are optional: *
*
* Presence packets are used for two purposes. First, to notify the server of our
* the clients current presence status. Second, they are used to subscribe and
@@ -104,10 +118,20 @@ public class Presence extends Packet {
this.mode = mode;
}
+ /**
+ * Returns the type of this presence packet.
+ *
+ * @return the type of the presence packet.
+ */
public Type getType() {
return type;
}
+ /**
+ * Sets the type of the presence packet.
+ *
+ * @param type the type of the presence packet.
+ */
public void setType(Type type) {
this.type = type;
}
@@ -181,7 +205,10 @@ public class Presence extends Packet {
if (getFrom() != null) {
buf.append("from=\"").append(getFrom()).append("\" ");
}
- buf.append("type=\"").append(type).append("\">");
+ if (type != Type.AVAILABLE) {
+ buf.append("type=\"").append(type).append("\"");
+ }
+ buf.append(">");
if (status != null) {
buf.append("