Search in sources :

Example 1 with PacketRejectedException

use of org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException in project Openfire by igniterealtime.

the class Chatbot method userDepartQueue.

private void userDepartQueue(Message message) {
    // Remove the user from the queue if he was waiting in the queue
    try {
        Request request = UserRequest.getRequest(workgroup, message.getFrom());
        InterceptorManager interceptorManager = QueueInterceptorManager.getInstance();
        try {
            interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), message, true, false);
            request.cancel(Request.CancelType.DEPART);
            // Remove the session (the goodbye message is sent when leaving the queue)
            removeSession(message.getFrom());
            interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), message, true, true);
        } catch (PacketRejectedException e) {
            workgroup.rejectPacket(message, e);
        }
    } catch (NotFoundException e) {
        // Send the goodbye message and close the session
        closeSession(message);
    }
}
Also used : InterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.InterceptorManager) QueueInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.QueueInterceptorManager) ChatbotInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.ChatbotInterceptorManager) Request(org.jivesoftware.xmpp.workgroup.request.Request) UserRequest(org.jivesoftware.xmpp.workgroup.request.UserRequest) PacketRejectedException(org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException) NotFoundException(org.jivesoftware.util.NotFoundException)

Example 2 with PacketRejectedException

use of org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException in project Openfire by igniterealtime.

the class Chatbot method userJoinQueue.

private void userJoinQueue(Message message, ChatbotSession session) {
    InterceptorManager interceptorManager = QueueInterceptorManager.getInstance();
    try {
        interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), message, true, false);
        if (getRoutingMessage() != null && getRoutingMessage().length() > 0) {
            sendReply(message, getRoutingMessage());
        }
        // Set that we are currently joining a waiting queue
        session.setCurrentStep(3);
        // Received a Join Queue request from a visitor, create a new request.
        UserRequest request = new UserRequest(session, workgroup);
        // Let the workgroup process the new request
        if (!workgroup.queueRequest(request)) {
            // It was not possible to add the request to a queue so send message saying that
            // the workgroup is not accepting new join requests
            sendReply(message, getCannotJoinMessage());
            // Send the goodbye message and close the session
            closeSession(message);
        } else {
            session.setRequest(request);
        }
        interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), message, true, true);
    } catch (PacketRejectedException e) {
        workgroup.rejectPacket(message, e);
    }
}
Also used : InterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.InterceptorManager) QueueInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.QueueInterceptorManager) ChatbotInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.ChatbotInterceptorManager) PacketRejectedException(org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException) UserRequest(org.jivesoftware.xmpp.workgroup.request.UserRequest)

Example 3 with PacketRejectedException

use of org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException in project Openfire by igniterealtime.

the class Chatbot method send.

private void send(Message packet) {
    InterceptorManager interceptorManager = ChatbotInterceptorManager.getInstance();
    try {
        interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), packet, false, false);
        workgroup.send(packet);
        interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), packet, false, true);
    } catch (PacketRejectedException e) {
        Log.warn("Packet was not sent " + "due to interceptor REJECTION: " + packet.toXML(), e);
    }
}
Also used : InterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.InterceptorManager) QueueInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.QueueInterceptorManager) ChatbotInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.ChatbotInterceptorManager) PacketRejectedException(org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException)

Example 4 with PacketRejectedException

use of org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException in project Openfire by igniterealtime.

the class Workgroup method send.

public void send(Packet packet) {
    InterceptorManager interceptorManager = WorkgroupInterceptorManager.getInstance();
    try {
        interceptorManager.invokeInterceptors(getJID().toBareJID(), packet, false, false);
        WorkgroupManager.getInstance().send(packet);
        interceptorManager.invokeInterceptors(getJID().toBareJID(), packet, false, true);
    } catch (PacketRejectedException e) {
        Log.warn("Packet was not sent " + "due to interceptor REJECTION: " + packet.toXML(), e);
    }
}
Also used : InterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.InterceptorManager) WorkgroupInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.WorkgroupInterceptorManager) RoomInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.RoomInterceptorManager) PacketRejectedException(org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException)

Example 5 with PacketRejectedException

use of org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException in project Openfire by igniterealtime.

the class AgentSession method sendOffer.

/**
     * Send an offer
     *
     * @param offer the <code>Offer</code> to send.
     * @param offerPacket the packet to send to the agent with the offer.
     * @return true if the packet was sent to the agent.
     */
public boolean sendOffer(Offer offer, IQ offerPacket) {
    synchronized (this) {
        if (this.offer != null) {
            return false;
        }
        this.offer = offer;
    }
    try {
        offer.addPendingSession(this);
        InterceptorManager interceptorManager = OfferInterceptorManager.getInstance();
        try {
            Workgroup workgroup = offer.getRequest().getWorkgroup();
            interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), offerPacket, false, false);
            // Send the Offer to the agent
            WorkgroupManager.getInstance().send(offerPacket);
            interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), offerPacket, false, true);
        } catch (PacketRejectedException e) {
            Log.warn("Offer was not sent " + "due to interceptor REJECTION: " + offerPacket.toXML(), e);
        }
        return true;
    } catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
        return false;
    }
}
Also used : OfferInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.OfferInterceptorManager) InterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.InterceptorManager) PacketRejectedException(org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException) PacketRejectedException(org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException)

Aggregations

InterceptorManager (org.jivesoftware.xmpp.workgroup.interceptor.InterceptorManager)9 PacketRejectedException (org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException)9 QueueInterceptorManager (org.jivesoftware.xmpp.workgroup.interceptor.QueueInterceptorManager)5 ChatbotInterceptorManager (org.jivesoftware.xmpp.workgroup.interceptor.ChatbotInterceptorManager)4 UserRequest (org.jivesoftware.xmpp.workgroup.request.UserRequest)3 NotFoundException (org.jivesoftware.util.NotFoundException)2 OfferInterceptorManager (org.jivesoftware.xmpp.workgroup.interceptor.OfferInterceptorManager)2 RoomInterceptorManager (org.jivesoftware.xmpp.workgroup.interceptor.RoomInterceptorManager)2 WorkgroupInterceptorManager (org.jivesoftware.xmpp.workgroup.interceptor.WorkgroupInterceptorManager)2 Request (org.jivesoftware.xmpp.workgroup.request.Request)2 IQ (org.xmpp.packet.IQ)2 JID (org.xmpp.packet.JID)2 Presence (org.xmpp.packet.Presence)2 Element (org.dom4j.Element)1 AgentInterceptorManager (org.jivesoftware.xmpp.workgroup.interceptor.AgentInterceptorManager)1 InvitationRequest (org.jivesoftware.xmpp.workgroup.request.InvitationRequest)1 TransferRequest (org.jivesoftware.xmpp.workgroup.request.TransferRequest)1 Message (org.xmpp.packet.Message)1 PacketError (org.xmpp.packet.PacketError)1