Search in sources :

Example 1 with StanzaHandler

use of org.jivesoftware.openfire.net.StanzaHandler in project Openfire by igniterealtime.

the class ConnectionHandler method messageReceived.

@Override
public void messageReceived(IoSession session, Object message) throws Exception {
    // Get the stanza handler for this session
    StanzaHandler handler = (StanzaHandler) session.getAttribute(HANDLER);
    // Get the parser to use to process stanza. For optimization there is going
    // to be a parser for each running thread. Each Filter will be executed
    // by the Executor placed as the first Filter. So we can have a parser associated
    // to each Thread
    final XMPPPacketReader parser = PARSER_CACHE.get();
    // Update counter of read btyes
    updateReadBytesCounter(session);
    // Let the stanza handler process the received stanza
    try {
        handler.process((String) message, parser);
    } catch (Exception e) {
        Log.error("Closing connection due to error while processing message: " + message, e);
        final Connection connection = (Connection) session.getAttribute(CONNECTION);
        if (connection != null) {
            connection.close();
        }
    }
}
Also used : XMPPPacketReader(org.dom4j.io.XMPPPacketReader) StanzaHandler(org.jivesoftware.openfire.net.StanzaHandler) Connection(org.jivesoftware.openfire.Connection) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Aggregations

XMPPPacketReader (org.dom4j.io.XMPPPacketReader)1 Connection (org.jivesoftware.openfire.Connection)1 StanzaHandler (org.jivesoftware.openfire.net.StanzaHandler)1 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)1