/** * Invite a user to a chat room. * * @param chatRoom the <code>ChatRoom</code> to invite or transfer. * @param sessionID the sessionID of this Fastpath session. * @param jid the jid of the room. * @param messageText the message to send to the user. * @param transfer true if this is a transfer. */ public static void transferOrInviteUser(ChatRoom chatRoom, String workgroup, String sessionID, final String jid, String messageText, final boolean transfer) { messageText = StringUtils.escapeForXML(messageText); String msg = messageText != null ? messageText : FpRes.getString("message.please.join.me.in.conference"); try { if (!transfer) { // TODO : CHECK FASHPATH FastpathPlugin.getAgentSession().sendRoomInvitation(RoomInvitation.Type.user, jid, sessionID, msg); } else { // TODO : CHECK FASHPATH FastpathPlugin.getAgentSession().sendRoomTransfer(RoomTransfer.Type.user, jid, sessionID, msg); } } catch (XMPPException e) { Log.error(e); } String username = SparkManager.getUserManager().getUserNicknameFromJID(jid); String notification = FpRes.getString("message.user.has.been.invited", username); if (transfer) { notification = FpRes.getString("message.waiting.for.user", username); } chatRoom.getTranscriptWindow().insertNotificationMessage(notification, ChatManager.NOTIFICATION_COLOR); }
/** * Invite or transfer a queue. * * @param chatRoom the <code>ChatRoom</code> to invite or transfer. * @param sessionID the sessionID of this Fastpath session. * @param jid the jid of the room. * @param messageText the message to send to the user. * @param transfer true if this is a transfer. */ public static void transferOrInviteToQueue(ChatRoom chatRoom, String workgroup, String sessionID, final String jid, String messageText, final boolean transfer) { messageText = StringUtils.escapeForXML(messageText); String msg = messageText != null ? messageText : FpRes.getString("message.please.join.me.in.conference"); try { if (!transfer) { // TODO : CHECK FASHPATH FastpathPlugin.getAgentSession().sendRoomInvitation(RoomInvitation.Type.queue, jid, sessionID, msg); } else { // TODO : CHECK FASHPATH FastpathPlugin.getAgentSession().sendRoomTransfer(RoomTransfer.Type.queue, jid, sessionID, msg); } } catch (XMPPException e) { Log.error(e); } String username = SparkManager.getUserManager().getUserNicknameFromJID(jid); String notification = FpRes.getString("message.user.has.been.invited", username); if (transfer) { notification = FpRes.getString("message.waiting.for.user", username); } chatRoom.getTranscriptWindow().insertNotificationMessage(notification, ChatManager.NOTIFICATION_COLOR); }
/** * Invite or transfer a queue. * * @param chatRoom the <code>ChatRoom</code> to invite or transfer. * @param sessionID the sessionID of this Fastpath session. * @param jid the jid of the room. * @param messageText the message to send to the user. * @param transfer true if this is a transfer. */ public static void transferOrInviteToWorkgroup(ChatRoom chatRoom, String workgroup, String sessionID, final String jid, String messageText, final boolean transfer) { messageText = StringUtils.escapeForXML(messageText); String msg = messageText != null ? messageText : FpRes.getString("message.please.join.me.in.conference"); try { if (!transfer) { // TODO : CHECK FASHPATH FastpathPlugin.getAgentSession().sendRoomInvitation(RoomInvitation.Type.workgroup, jid, sessionID, msg); } else { FastpathPlugin.getAgentSession().sendRoomTransfer(RoomTransfer.Type.workgroup, jid, sessionID, msg); } } catch (XMPPException e) { Log.error(e); } String username = SparkManager.getUserManager().getUserNicknameFromJID(jid); String notification = FpRes.getString("message.user.has.been.invited", username); if (transfer) { notification = FpRes.getString("message.waiting.for.user", username); } chatRoom.getTranscriptWindow().insertNotificationMessage(notification, ChatManager.NOTIFICATION_COLOR); }
/** * Transfer an existing session support to another user or agent. The provided invitee's JID can be of * a user, an agent, a queue or a workgroup. In the case of a queue or a workgroup the workgroup service * will decide the best agent to receive the invitation.<p> * * This method will return either when the service returned an ACK of the request or if an error occured * while requesting the transfer. After sending the ACK the service will send the invitation to the target * entity. When dealing with agents the common sequence of offer-response will be followed. However, when * sending an invitation to a user a standard MUC invitation will be sent.<p> * * Once the invitee joins the support room the workgroup service will kick the inviter from the room.<p> * * Different situations may lead to a failed transfers. Possible cases are: 1) all agents rejected the * offer and there are no agents available, 2) the agent that accepted the offer failed to join the room * or 2) the user that received the MUC invitation never replied or joined the room. In any of these cases * (or other failing cases) the inviter will get an error message with the failed notification. * * @param type type of entity that will get the invitation. * @param invitee JID of entity that will get the invitation. * @param sessionID ID of the support session that the invitee is being invited. * @param reason the reason of the invitation. * @throws XMPPErrorException if the sender of the invitation is not an agent or the service failed to process * the request. * @throws NoResponseException * @throws NotConnectedException */ public void sendRoomTransfer(RoomTransfer.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException { final RoomTransfer transfer = new RoomTransfer(type, invitee, sessionID, reason); IQ iq = new RoomTransfer.RoomTransferIQ(transfer); iq.setType(IQ.Type.set); iq.setTo(workgroupJID); iq.setFrom(connection.getUser()); connection.createPacketCollectorAndSend(iq).nextResultOrThrow(); }