
package org.livetribe.slp.spi;

import java.net.InetSocketAddress;

import org.livetribe.slp.SLPError;
import org.livetribe.slp.settings.Settings;
import org.livetribe.slp.spi.msg.Message;
import org.livetribe.slp.spi.msg.SrvAck;
import org.livetribe.slp.spi.net.UDPConnector;


/**
 *
 */
public class UDPSrvAckPerformer extends SrvAckPerformer
{
    private final UDPConnector udpConnector;

    public UDPSrvAckPerformer(UDPConnector udpConnector, Settings settings)
    {
        this.udpConnector = udpConnector;
    }

    public void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, Message message, SLPError error)
    {
        SrvAck srvAck = newSrvAck(message, error);
        byte[] bytes = srvAck.serialize();
        udpConnector.send(localAddress.getAddress().getHostAddress(), remoteAddress, bytes);
    }
}
