/** * 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); }
/** * Invites a user or agent to an existing session support. 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 invitation. 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> * * The agent or user that accepted the offer <b>MUST</b> join the room. Failing to do so will make * the invitation to fail. The inviter will eventually receive a message error indicating that the invitee * accepted the offer but failed to join the room. * * Different situations may lead to a failed invitation. Possible cases are: 1) all agents rejected the * offer and ther 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 sendRoomInvitation(RoomInvitation.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException { final RoomInvitation invitation = new RoomInvitation(type, invitee, sessionID, reason); IQ iq = new RoomInvitation.RoomInvitationIQ(invitation); iq.setType(IQ.Type.set); iq.setTo(workgroupJID); iq.setFrom(connection.getUser()); connection.createPacketCollectorAndSend(iq).nextResultOrThrow(); }