Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to change presence status of my user with Smack

Tags:

xmpp

smack

I tried to set online mode but it doesn't work through a Roster. I ran this code and check my localhost server, the mode still "available" and not "Do not disturb".

final Connection connection = new XMPPConnection("xxx.xxx.x.xx");

connection.connect();
connection.login("hieugioi@hieund", "123456");

final Roster roster = connection.getRoster();           
Presence p = roster.getPresence("hieugioi@hieund");
p.setPriority(128);
p.setMode(Mode.dnd);
like image 594
emeraldhieu Avatar asked Dec 18 '12 08:12

emeraldhieu


Video Answer


1 Answers

Because you don't send the Presence packet to the server. After you have assembled your Presence packet you need to send it. For example:

Presence p = new Presence(available, "I am busy", 42, Mode.dnd);
connection.sendStanza(p);

See also: Smack - Getting Started; section "Reading and Writing Packets"

like image 191
Flow Avatar answered Sep 21 '22 07:09

Flow