use of org.xmpp.muc.Invitation in project Openfire by igniterealtime.
the class Workgroup method sendInvitation.
/**
* An agent has accepted the offer and was choosen to answer the user's requests. The workgroup
* will create a new room where the agent can answer the user's needs. Once the room has been
* created, the Agent and the user that made the request will receive invitiations to join the
* newly created room.<p>
* <p/>
* The workgroup will listen for all the packets sent to the room and generate a conversation
* transcript.
*
* @param agent the AgentSession that accepted and was choosen to respond the user's requests.
* @param request the request made by a user.
*/
public void sendInvitation(AgentSession agent, UserRequest request) {
// we need to destroy all MUC rooms created by workgroups
try {
RoomInterceptorManager interceptorManager = RoomInterceptorManager.getInstance();
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
String userJID = request.getUserJID().toString();
final Workgroup sessionWorkgroup = request.getWorkgroup();
final String sessionID = request.getSessionID();
String workgroupName = getJID().getNode();
final String serviceName = workgroupManager.getMUCServiceName();
final String roomName = sessionID + "@" + serviceName;
final String roomJID = roomName + "/" + workgroupName;
// Create the room by joining it. The workgroup will be the owner of the room and will
// invite the Agent and the user to join the room
JoinRoom joinRoom = new JoinRoom(getFullJID().toString(), roomJID);
interceptorManager.invokeInterceptors(getJID().toBareJID(), joinRoom, false, false);
send(joinRoom);
interceptorManager.invokeInterceptors(getJID().toBareJID(), joinRoom, false, true);
// Configure the newly created room
Map<String, Collection<String>> fields = new HashMap<String, Collection<String>>();
// Make a non-public room
List<String> values = new ArrayList<String>();
values.add("0");
fields.put("muc#roomconfig_publicroom", values);
// Set the room description
values = new ArrayList<String>();
values.add(roomName);
fields.put("muc#roomconfig_roomdesc", values);
// Set that anyone can change the room subject
values = new ArrayList<String>();
values.add("1");
fields.put("muc#roomconfig_changesubject", values);
// Make the room temporary
values = new ArrayList<String>();
values.add("0");
fields.put("muc#roomconfig_persistentroom", values);
// Set that only moderators can see the occupants' JID
values = new ArrayList<String>();
values.add("moderators");
fields.put("muc#roomconfig_whois", values);
// Set that we want packets to include the real JID
values = new ArrayList<String>();
values.add("0");
fields.put("anonymous", values);
// Only broadcast presences of participants and visitors
values = new ArrayList<String>();
values.add("participant");
values.add("visitor");
fields.put("muc#roomconfig_presencebroadcast", values);
RoomConfiguration conf = new RoomConfiguration(fields);
conf.setTo(roomName);
conf.setFrom(getFullJID());
interceptorManager.invokeInterceptors(getJID().toBareJID(), conf, false, false);
send(conf);
interceptorManager.invokeInterceptors(getJID().toBareJID(), conf, false, true);
// 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);
// 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);
// Invite the user to the new room
sendUserInvitiation(request, roomName);
// Notify the request that invitations for support have been sent
request.invitationsSent(sessionID);
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
use of org.xmpp.muc.Invitation in project Openfire by igniterealtime.
the class Workgroup method sendUserInvitiation.
/**
* Sends the room invitation to the user that made the request.
*
* @param request the Request that the user made to join a workgroup.
* @param roomID the id of the room where the user is being invited.
*/
public void sendUserInvitiation(UserRequest request, String roomID) {
String userJID = request.getUserJID().toString();
final String sessionID = request.getSessionID();
final String serviceName = WorkgroupManager.getInstance().getMUCServiceName();
final String roomName = sessionID + "@" + serviceName;
Invitation invitation = new Invitation(userJID, "Please join me for a chat.");
invitation.setTo(roomName);
invitation.setFrom(getFullJID());
// Add workgroup extension that includes the JID of the workgroup
Element element = invitation.addChildElement("workgroup", "http://jabber.org/protocol/workgroup");
element.addAttribute("jid", getJID().toBareJID());
// Add custom extension that includes the sessionID
element = invitation.addChildElement("session", "http://jivesoftware.com/protocol/workgroup");
element.addAttribute("id", sessionID);
RoomInterceptorManager interceptorManager = RoomInterceptorManager.getInstance();
interceptorManager.invokeInterceptors(getJID().toBareJID(), invitation, false, false);
send(invitation);
interceptorManager.invokeInterceptors(getJID().toBareJID(), invitation, false, true);
}
use of org.xmpp.muc.Invitation in project Openfire by igniterealtime.
the class InvitationRequest method sendMUCInvitiation.
/**
* Sends a standard MUC invitation to the invitee.
*/
private void sendMUCInvitiation() {
final String serviceName = WorkgroupManager.getInstance().getMUCServiceName();
final String roomName = sessionID + "@" + serviceName;
Invitation invitation = new Invitation(invitee.toString(), reason);
invitation.setTo(roomName);
invitation.setFrom(inviter);
// Add workgroup extension that includes the JID of the workgroup
Element element = invitation.addChildElement("workgroup", "http://jabber.org/protocol/workgroup");
element.addAttribute("jid", workgroup.getJID().toBareJID());
// Add custom extension that includes the sessionID
element = invitation.addChildElement("session", "http://jivesoftware.com/protocol/workgroup");
element.addAttribute("id", sessionID);
RoomInterceptorManager interceptorManager = RoomInterceptorManager.getInstance();
interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), invitation, false, false);
workgroup.send(invitation);
interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), invitation, false, true);
}
use of org.xmpp.muc.Invitation in project Openfire by igniterealtime.
the class TransferRequest method sendMUCInvitiation.
/**
* Sends a standard MUC invitation to the invitee.
*/
private void sendMUCInvitiation() {
// Keep track of the actual entity that received the transfer offer
actualInvitee = invitee;
final String serviceName = WorkgroupManager.getInstance().getMUCServiceName();
final String roomName = sessionID + "@" + serviceName;
Invitation invitation = new Invitation(invitee.toString(), reason);
invitation.setTo(roomName);
invitation.setFrom(inviter);
// Add workgroup extension that includes the JID of the workgroup
Element element = invitation.addChildElement("workgroup", "http://jabber.org/protocol/workgroup");
element.addAttribute("jid", workgroup.getJID().toBareJID());
// Add custom extension that includes the sessionID
element = invitation.addChildElement("session", "http://jivesoftware.com/protocol/workgroup");
element.addAttribute("id", sessionID);
RoomInterceptorManager interceptorManager = RoomInterceptorManager.getInstance();
interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), invitation, false, false);
workgroup.send(invitation);
interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), invitation, false, true);
}
Aggregations