package com.blazemeter.jmeter.xmpp.actions;


import com.blazemeter.jmeter.xmpp.JMeterXMPPSampler;
import org.apache.jmeter.samplers.SampleResult;
import org.jivesoftware.smack.AbstractXMPPConnection;

import javax.swing.*;
import java.awt.*;

public class Connect extends AbstractXMPPAction {
    @Override
    public String getLabel() {
        return "Connect to Server";
    }

    @Override
    public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
        AbstractXMPPConnection conn = (AbstractXMPPConnection)sampler.getXMPPConnection();
        conn.connect();
        res.setResponseData(sampler.getXMPPConnection().getConnectionID().getBytes());
        return res;
    }

    @Override
    public void addUI(JComponent panel, GridBagConstraints labelConstraints, GridBagConstraints editConstraints) {

    }

    @Override
    public void clearGui() {

    }

    @Override
    public void setSamplerProperties(JMeterXMPPSampler sampler) {

    }

    @Override
    public void setGuiFieldsFromSampler(JMeterXMPPSampler sampler) {

    }
}
