mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Use new presence types.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1794 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
e83cc69730
commit
642396a100
3 changed files with 11 additions and 12 deletions
|
@ -107,7 +107,7 @@ public class GroupChat {
|
|||
}
|
||||
// We join a room by sending a presence packet where the "to"
|
||||
// field is in the form "roomName@service/nickname"
|
||||
Presence joinPresence = new Presence(true);
|
||||
Presence joinPresence = new Presence(Presence.Type.AVAILABLE);
|
||||
joinPresence.setTo(room + "/" + nickname);
|
||||
connection.getPacketWriter().sendPacket(joinPresence);
|
||||
// Wait for a presence packet back from the server.
|
||||
|
@ -139,7 +139,7 @@ public class GroupChat {
|
|||
}
|
||||
// We leave a room by sending a presence packet where the "to"
|
||||
// field is in the form "roomName@service/nickname"
|
||||
Presence leavePresence = new Presence(false);
|
||||
Presence leavePresence = new Presence(Presence.Type.UNAVAILABLE);
|
||||
leavePresence.setTo(room + "/" + nickname);
|
||||
connection.getPacketWriter().sendPacket(leavePresence);
|
||||
nickname = null;
|
||||
|
|
|
@ -440,16 +440,15 @@ public class PacketReader {
|
|||
* @throws Exception if an exception occurs while parsing the packet.
|
||||
*/
|
||||
private static Packet parsePresence(XmlPullParser parser) throws Exception {
|
||||
String type = parser.getAttributeValue("", "type");
|
||||
// If the type value isn't set, it should default to available.
|
||||
if (type == null) {
|
||||
type = "available";
|
||||
}
|
||||
Presence.Type type = Presence.Type.fromString(parser.getAttributeValue("", "type"));
|
||||
// We only handle "available" or "unavailable" packets for now.
|
||||
if (!(type.equals("available") || type.equals("unavailable"))) {
|
||||
if (!(type == Presence.Type.AVAILABLE || type == Presence.Type.UNAVAILABLE)) {
|
||||
System.out.println("FOUND OTHER PRESENCE TYPE: " + type);
|
||||
}
|
||||
Presence presence = new Presence("available".equals(type));
|
||||
|
||||
// Otherwise, it's a presence packet that has nothing to do with roster items.
|
||||
|
||||
Presence presence = new Presence(type);
|
||||
presence.setTo(parser.getAttributeValue("", "to"));
|
||||
presence.setFrom(parser.getAttributeValue("", "from"));
|
||||
presence.setPacketID(parser.getAttributeValue("", "id"));
|
||||
|
|
|
@ -81,7 +81,7 @@ import java.awt.*;
|
|||
*/
|
||||
public class XMPPConnection {
|
||||
|
||||
private static final String NEWLINE = System.getProperty ("line.separator");
|
||||
private static final String NEWLINE = System.getProperty("line.separator");
|
||||
|
||||
/**
|
||||
* Value that indicates whether debugging is enabled. When enabled, a debug
|
||||
|
@ -272,7 +272,7 @@ public class XMPPConnection {
|
|||
// We're done with the collector, so explicitly cancel it.
|
||||
collector.cancel();
|
||||
// Set presence to online.
|
||||
packetWriter.sendPacket(new Presence(true));
|
||||
packetWriter.sendPacket(new Presence(Presence.Type.AVAILABLE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,7 +319,7 @@ public class XMPPConnection {
|
|||
*/
|
||||
public void close() {
|
||||
// Set presence to offline.
|
||||
packetWriter.sendPacket(new Presence(false));
|
||||
packetWriter.sendPacket(new Presence(Presence.Type.UNAVAILABLE));
|
||||
packetWriter.shutdown();
|
||||
packetReader.shutdown();
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue