Search in sources :

Example 16 with Message

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

the class GojaraAdminProcessor method process.

/**
	 * Here we process the response of the remote command sent to Spectrum. We have to identify what kind of response it
	 * is, as no tag for the command being responded is being sent. Currently these commands are used in Gojara
	 * TransportSessionManager: online_users ( Chatmsg of online users for specific transport), usernames seperated by
	 * newlines
	 */
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
    Message message = (Message) packet;
    // handle different commands
    Log.debug("Intercepted spectrum message: " + message.toString());
    String command = packet.getID();
    if (command.equals("online_users")) {
        handleOnlineUsers(message, subdomain);
    } else if (command.equals("unregister")) {
        handleUnregister(message, subdomain);
    } else if (command.equals("config_check")) {
        handleConfigCheck(subdomain);
    } else if (command.equals("uptime")) {
        handleStatistic(message, subdomain, "uptime");
    } else if (command.equals("messages_from_xmpp")) {
        handleStatistic(message, subdomain, "messages_from_xmpp");
    } else if (command.equals("messages_to_xmpp")) {
        handleStatistic(message, subdomain, "messages_to_xmpp");
    } else if (command.equals("used_memory")) {
        handleStatistic(message, subdomain, "used_memory");
    } else if (command.equals("average_memory_per_user")) {
        handleStatistic(message, subdomain, "average_memory_per_user");
    }
}
Also used : Message(org.xmpp.packet.Message)

Example 17 with Message

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

the class Chatbot method sendQuestion.

private void sendQuestion(Message message, ChatbotSession session, int position) {
    FormElement field = getForm().getFormElementAt(position);
    if (field == null) {
        return;
    }
    if (field.getAnswerType() == WorkgroupForm.FormEnum.hidden) {
        // Auto accept hidden fields
        Message fakeMessage = message.createCopy();
        StringBuilder builder = new StringBuilder();
        for (Iterator<String> it = field.getAnswers().iterator(); it.hasNext(); ) {
            builder.append(it.next());
            if (it.hasNext()) {
                builder.append("/");
            }
        }
        fakeMessage.setBody(builder.toString());
        // Set that we are currently waiting for a response to the next question
        session.setCurrentSubstep(position);
        // Simulate that the user sent this message (with the hidden field)
        onMessage(session, fakeMessage);
    }
    String text = field.getLabel();
    if (field.getAnswerType() == WorkgroupForm.FormEnum.radio_button || field.getAnswerType() == WorkgroupForm.FormEnum.dropdown_box || field.getAnswerType() == WorkgroupForm.FormEnum.checkbox) {
        // Append the options to the message body
        if (!field.getAnswers().isEmpty()) {
            StringBuilder builder = new StringBuilder(text);
            builder.append(" [");
            builder.append(Request.encodeMetadataValue(field.getAnswers()));
            builder.append("]");
            text = builder.toString();
        }
    }
    sendReply(message, text);
    // Set that we are currently waiting for a response to the next question
    session.setCurrentSubstep(position);
}
Also used : Message(org.xmpp.packet.Message) FormElement(org.jivesoftware.openfire.fastpath.dataforms.FormElement)

Example 18 with Message

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

the class GojaraAdminManager method testAdminConfiguration.

/**
	 * Sends a testmessage to specified gateway, when a response gets intercepted we consider gateway configured
	 * 
	 */
public void testAdminConfiguration(String gateway) {
    unconfiguredGateways.add(gateway);
    Message message = generateCommand(gateway, "config_check");
    message.setBody("status");
    router.route(message);
    Log.info("Checking for admin configuration on " + gateway);
}
Also used : Message(org.xmpp.packet.Message)

Example 19 with Message

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

the class GojaraAdminManager method usedMemoryOf.

private void usedMemoryOf(String transport) {
    Message message = generateCommand(transport, "used_memory");
    router.route(message);
}
Also used : Message(org.xmpp.packet.Message)

Example 20 with Message

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

the class GojaraAdminManager method averageMemoryOfUser.

private void averageMemoryOfUser(String transport) {
    Message message = generateCommand(transport, "average_memory_per_user");
    router.route(message);
}
Also used : Message(org.xmpp.packet.Message)

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