// Create a new entry for the active session and the request made by the user
requests.put(sessionID, request);
// Invite the Agent to the new room
Invitation invitation = new Invitation(agent.getJID().toString(), sessionID);
invitation.setTo(roomName);
invitation.setFrom(getFullJID());
// Add workgroup extension that includes the JID of the user that made the request
Element element = invitation.addChildElement("offer", "http://jabber.org/protocol/workgroup");
element.addAttribute("jid", userJID);
// Add custom extension that includes the sessionID
element = invitation.addChildElement("session", "http://jivesoftware.com/protocol/workgroup");
element.addAttribute("workgroup", sessionWorkgroup.getJID().toString());
element.addAttribute("id", sessionID);
// Add custom extension that includes the userID if the session belongs to an
// anonymous user
if (request.isAnonymousUser()) {
element = invitation.addChildElement("user", "http://jivesoftware.com/protocol/workgroup");
element.addAttribute("id", request.getUserID());
}
interceptorManager.invokeInterceptors(getJID().toBareJID(), invitation, false, false);
send(invitation);
interceptorManager.invokeInterceptors(getJID().toBareJID(), invitation, false, true);