aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/xmpp/disco/ServiceDiscoveryIqPacketHandler.java
blob: 6f1b0676932c5f129eb8670bc9d94afeb4b0daf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package de.thedevstack.conversationsplus.xmpp.disco;

import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.utils.XmppSendUtil;
import de.thedevstack.conversationsplus.xmpp.IqPacketHandler;
import de.thedevstack.conversationsplus.xmpp.exceptions.IqPacketErrorException;
import de.thedevstack.conversationsplus.xmpp.exceptions.NotAllowedIqException;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;

/**
 */
public class ServiceDiscoveryIqPacketHandler implements IqPacketHandler {
    @Override
    public void handleIqPacket(Account account, IqPacket packet) throws IqPacketErrorException {
        if (packet.getType() == IqPacket.TYPE.GET) {
            XmppSendUtil.sendIqPacket(account, ServiceDiscoveryIqPacketGenerator.generateResponse(packet));
        } else {
            throw new NotAllowedIqException(packet, "only type=get allowed for processing an service discovery (XEP-0030)");
        }
    }
}