0
用戶添加其他用戶sanika
。但是當tester
檢查sanika
的狀態時,他得到subscribe
。爲什麼這樣?爲什麼我獲得「訂閱」狀態?對於<code>sanika</code>被設置爲<strong><em><code>Roster.SubscriptionMode.accept_all</code></em></strong>在他roster.The訂閱模式命名爲<code>tester</code>
在函數main中,sanika
設置她的狀態並在函數connectTester
測試器中嘗試獲取sanika
的狀態。
public static void main(String[] args) {
try {
Connection connection = new XMPPConnection("localhost");
connection.connect();
connection.login("sanika", "tester");
Roster r = connection.getRoster();
r.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
Presence p = new Presence(Presence.Type.available);
p.setStatus("Having Lunch :)");
connection.sendPacket(p);
connectTester();
Thread.sleep(30000);
} catch(Exception exc) {
exc.printStackTrace();
}
}
public static void connectTester() {
try {
Connection connection = new XMPPConnection("localhost");
connection.connect();
connection.login("tester", "tester");
Roster r = connection.getRoster();
RosterEntry re = r.getEntry("[email protected]");
System.out.println(re.getStatus().toString());
// PRINTS SUBSCRIBE
}catch(Exception exc) {}
我在哪裏犯了一個錯誤?
注:tester
添加sanika
爲:
String group[] = {"Friend List"};
r.createGroup("Friend List");
r.createEntry("[email protected]", "sanika", group);
我發佈了一個查詢..如果我們可以在這裏討論它http://chat.stackoverflow.com/rooms/40703/discussion-between-suhail-and-marc-van-daele –
我發佈了一個查詢那裏 –