mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +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"
|
// We join a room by sending a presence packet where the "to"
|
||||||
// field is in the form "roomName@service/nickname"
|
// field is in the form "roomName@service/nickname"
|
||||||
Presence joinPresence = new Presence(true);
|
Presence joinPresence = new Presence(Presence.Type.AVAILABLE);
|
||||||
joinPresence.setTo(room + "/" + nickname);
|
joinPresence.setTo(room + "/" + nickname);
|
||||||
connection.getPacketWriter().sendPacket(joinPresence);
|
connection.getPacketWriter().sendPacket(joinPresence);
|
||||||
// Wait for a presence packet back from the server.
|
// 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"
|
// We leave a room by sending a presence packet where the "to"
|
||||||
// field is in the form "roomName@service/nickname"
|
// field is in the form "roomName@service/nickname"
|
||||||
Presence leavePresence = new Presence(false);
|
Presence leavePresence = new Presence(Presence.Type.UNAVAILABLE);
|
||||||
leavePresence.setTo(room + "/" + nickname);
|
leavePresence.setTo(room + "/" + nickname);
|
||||||
connection.getPacketWriter().sendPacket(leavePresence);
|
connection.getPacketWriter().sendPacket(leavePresence);
|
||||||
nickname = null;
|
nickname = null;
|
||||||
|
|
|
@ -440,16 +440,15 @@ public class PacketReader {
|
||||||
* @throws Exception if an exception occurs while parsing the packet.
|
* @throws Exception if an exception occurs while parsing the packet.
|
||||||
*/
|
*/
|
||||||
private static Packet parsePresence(XmlPullParser parser) throws Exception {
|
private static Packet parsePresence(XmlPullParser parser) throws Exception {
|
||||||
String type = parser.getAttributeValue("", "type");
|
Presence.Type type = Presence.Type.fromString(parser.getAttributeValue("", "type"));
|
||||||
// If the type value isn't set, it should default to available.
|
|
||||||
if (type == null) {
|
|
||||||
type = "available";
|
|
||||||
}
|
|
||||||
// We only handle "available" or "unavailable" packets for now.
|
// 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);
|
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.setTo(parser.getAttributeValue("", "to"));
|
||||||
presence.setFrom(parser.getAttributeValue("", "from"));
|
presence.setFrom(parser.getAttributeValue("", "from"));
|
||||||
presence.setPacketID(parser.getAttributeValue("", "id"));
|
presence.setPacketID(parser.getAttributeValue("", "id"));
|
||||||
|
|
|
@ -81,7 +81,7 @@ import java.awt.*;
|
||||||
*/
|
*/
|
||||||
public class XMPPConnection {
|
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
|
* 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.
|
// We're done with the collector, so explicitly cancel it.
|
||||||
collector.cancel();
|
collector.cancel();
|
||||||
// Set presence to online.
|
// 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() {
|
public void close() {
|
||||||
// Set presence to offline.
|
// Set presence to offline.
|
||||||
packetWriter.sendPacket(new Presence(false));
|
packetWriter.sendPacket(new Presence(Presence.Type.UNAVAILABLE));
|
||||||
packetWriter.shutdown();
|
packetWriter.shutdown();
|
||||||
packetReader.shutdown();
|
packetReader.shutdown();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue