Who give me example about AdHocCommand use the newest api

who give me a example about AdHocCommand use the newest api

Here’s a very simple example for getting the number of online users using Smack 3.3.1:

AdHocCommandManager manager = AdHocCommandManager.getAddHocCommandsManager(connection);

// You can use manager.discoverCommands(jid) to get all supported commands

*// This is the node for the command (see http://xmpp.org/extensions/xep-0133.html) *

String node = “http://jabber.org/protocol/admin#get-online-users-num”;

RemoteCommand command = manager.getRemoteCommand(jid, node);

command.execute();

// The answer will return a field with the var “onlineusersnum” which has just one value

String numberOfUsers = command.getForm().getField(“onlineusersnum”).next();