I’ve been searching through the API’s for implementing ad-hoc commands and now I’m using Smack and the ad-hoc command source code from the repository: http://svn.igniterealtime.org/svn/repos/smack/trunk/source/org/jivesoftware/smac kx/commands/
But I still can’t figure out how to use the source code and have struggled for some time… I’ve seen some discussion here, which was helpful but not sufficient for me ( because this is the first time I try Smack and XMPP).
What I have done is to create a connection associated with an AdHocCommandManager, then login to the server (e.g., jabber.org). Also, I have implemented an ad-hoc command (say, ReadPort.java, which extends LocalCommand).
Now my questions are:
Should I use AdHocCommandManager.registerCommand() to add the command (ReadPort.class) to the ower’s account (say, email@example.com/Home)
After I finish step 1, how can I remotely execute this ad-hoc command? I can’t figure out how the responder can know where to find the corresponding class to run (e.g. ReadPort.java). It seems to me that AdHocCommandManager.registerCommand() only uses the command class to initialize the AdHocCommandInfo local variable, but I couldn’t see where my command class will be invoked.
What’s the difference between AdHocCommandManager.processAdHocCommand() and RemoteCommand.execute() except one is private and the other is public? It seems that AdHocCommandManager.processAdHocCommand() is called in AdHocCommandManager.init(), however, AdHocCommandManager.init() is called from AdHocCommandManager’s constructor when the ad-hoc command hasn’t been specified, though.
I’m quite confused and really need help from you all. Is there any java example that can help me get started?
I will really really appreciate your help!!