Search in sources :

Example 96 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class Chatbot method notifyQueueStatus.

public void notifyQueueStatus(JID sender, JID receiver, UserRequest request, boolean isPolling) {
    // Get the chatbot session of the user
    ChatbotSession session = getSession(receiver, false);
    if (session != null) {
        Message packet = new Message();
        packet.setTo(receiver);
        packet.setFrom(sender);
        packet.setThread(session.getMessageThread());
        if (session.getMessageThread() != null) {
            packet.setType(Message.Type.chat);
        }
        String body = getPositionMessage().replace("${position}", String.valueOf(request.getPosition() + 1));
        body = body.replace("${waitTime}", String.valueOf(request.getTimeStatus()));
        packet.setBody(body);
        send(packet);
    }
}
Also used : Message(org.xmpp.packet.Message)

Example 97 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class InvitationRequest method sendErrorMessage.

private void sendErrorMessage(String body) {
    // Invitation request has failed. Inform inviter
    userRequest.removeRelatedRequest(this);
    Message message = new Message();
    message.setError(PacketError.Condition.recipient_unavailable);
    message.setTo(inviter);
    message.setFrom(workgroup.getJID());
    message.setBody(body);
    Element element = message.addChildElement("invite", "http://jabber.org/protocol/workgroup");
    element.addAttribute("type", type.toString());
    Element sessionElement = element.addElement("session", "http://jivesoftware.com/protocol/workgroup");
    sessionElement.addAttribute("id", sessionID);
    element.addElement("inviter").setText(inviter.toString());
    element.addElement("invitee").setText(invitee.toString());
    workgroup.send(message);
}
Also used : Message(org.xmpp.packet.Message) Element(org.dom4j.Element)

Example 98 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class TransferRequest method sendErrorMessage.

private void sendErrorMessage(String body) {
    // Invitation request has failed. Inform inviter
    userRequest.removeRelatedRequest(this);
    Message message = new Message();
    message.setError(PacketError.Condition.recipient_unavailable);
    message.setTo(inviter);
    message.setFrom(workgroup.getJID());
    message.setBody(body);
    Element element = message.addChildElement("transfer", "http://jabber.org/protocol/workgroup");
    element.addAttribute("type", type.toString());
    Element sessionElement = element.addElement("session", "http://jivesoftware.com/protocol/workgroup");
    sessionElement.addAttribute("id", sessionID);
    element.addElement("inviter").setText(inviter.toString());
    element.addElement("invitee").setText(invitee.toString());
    workgroup.send(message);
}
Also used : Message(org.xmpp.packet.Message) Element(org.dom4j.Element)

Example 99 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class BroadcastMessage method readExternal.

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
    packet = new Message(packetElement, true);
}
Also used : Message(org.xmpp.packet.Message) DefaultElement(org.dom4j.tree.DefaultElement) Element(org.dom4j.Element)

Example 100 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class RemotePacketExecution method readExternal.

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    recipient = (JID) ExternalizableUtil.getInstance().readSerializable(in);
    int packetType = ExternalizableUtil.getInstance().readInt(in);
    Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
    switch(packetType) {
        case 1:
            packet = new IQ(packetElement, true);
            break;
        case 2:
            packet = new Message(packetElement, true);
            break;
        case 3:
            packet = new Presence(packetElement, true);
            break;
    }
}
Also used : Message(org.xmpp.packet.Message) DefaultElement(org.dom4j.tree.DefaultElement) Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ) Presence(org.xmpp.packet.Presence)

Aggregations

Message (org.xmpp.packet.Message)111 Element (org.dom4j.Element)35 JID (org.xmpp.packet.JID)25 Test (org.junit.Test)23 Presence (org.xmpp.packet.Presence)18 IQ (org.xmpp.packet.IQ)16 ArrayList (java.util.ArrayList)10 Packet (org.xmpp.packet.Packet)10 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)9 Date (java.util.Date)6 ClientSession (org.jivesoftware.openfire.session.ClientSession)6 NotFoundException (org.jivesoftware.util.NotFoundException)6 StringReader (java.io.StringReader)4 List (java.util.List)4 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)4 User (org.jivesoftware.openfire.user.User)4 IOException (java.io.IOException)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 SAXReader (org.dom4j.io.SAXReader)3 DefaultElement (org.dom4j.tree.DefaultElement)3