From my understanding while digging in the smackx source code, as it has not much of the sample over SmackX with fastpath, each of the workgroups will have it’s own AgentSession to associated with.
Steps:
-
Once you had loggedin to Openfire, you need to use the AgentSession object, provide it with the specific workgroup and the connection object.
-
Then use the AgentSession object to setthe online status with AgentSession.SetOnline(true).
-
Manage the fastpath event with it’s listener including WorkgroupInvitationListener, OfferListener, QueueUsersListener
-
Each of the opened question from the workgroup will be notify via OfferListener, that need to be accept() or reject().
4.1 Whether accept() the offer then manage to get the muc invitation, and carrys on.
Some snippets that might be helpful:)
Login FastPath (create the AgentSession for each workgroup)
I had the FastPathAgent class which extends from the custom SmackClient class hence the login process of Openfire is managed in SmackClient.login()
public boolean loginFastPath() throws XMPPException, InterruptedException
{
super.login();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(super.getConnection());
DiscoverItems discoItems = discoManager.discoverItems(“workgroup.” + super.getConnection().getServiceName());
while(discoItems.getItems().hasNext())
{
Item item = discoItems.getItems().next();
getLogger().debug(String.format(“EntityID:%s, Name:%s, Node:%s”,
item.getEntityID(),
item.getName(),
item.getNode()));
}
String[] workgroups = getAssosicatedWorkgroups();
for(String workgroup : workgroups)
{
AgentSession agentSession = new AgentSession(workgroup,super.getConnection());
_agentSessionCollection.put(workgroup, agentSession);
}
FastPathStorage.addListener(this);
return true;
}
Online the agent in that workgroup
I need to manage each of the workgroup seperately hence each of the handler will be stored and manage outer.
public boolean setOnline(String workgroup) throws XMPPException
{
_agentSessionCollection.get(workgroup).setOnline(true);
FastPathInvitationHandler fpInvitationHandler = new FastPathInvitationHandler();
FastPathOfferHandler fpOfferHandler = new FastPathOfferHandler();
FastPathQueueHandler fpQHandler = new FastPathQueueHandler();
_agentHandlerCollection.put(workgroup,
new FastPathHandler(fpInvitationHandler, fpOfferHandler, fpQHandler));
_agentSessionCollection.get(workgroup).addInvitationListener(fpInvita tionHandler);
_agentSessionCollection.get(workgroup).addOfferListener(fpOfferHandle r);
_agentSessionCollection.get(workgroup).addQueueUsersListener(fpQHandl er);
return _agentSessionCollection.get(workgroup).isOnline();
}
Retrieve the workgroups
public String[] getAssosicatedWorkgroups() throws XMPPException
{
List workgroupList = new ArrayList();
for(String workGroup : Agent.getWorkgroups(“workgroup.” + super.getConnection().getServiceName(),
super.getUserBareJID(),
super.getConnection()))
{
getLogger().info("WORKGROUP : " + workGroup);
workgroupList.add(workGroup);
}
_assosicatedWorkgroups = (String[])workgroupList.toArray();
return _assosicatedWorkgroups;
}
Some of the naming may be awkard, since I am a newbie in Java