package com.jscape.inet.ssh.protocol.v2.messages;

import com.jscape.inet.ssh.protocol.messages.Message;
import com.jscape.util.net.connection.MessageConnection;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * @author Alex Usun
 */
public class SshMsgServiceAccept
        extends Message<SshMsgServiceAccept.Handler> {

    public final String serviceName;

    public SshMsgServiceAccept(String serviceName) {
        assertNotNull(serviceName);
        this.serviceName = serviceName;
    }

    public SshMsgServiceAccept(ServiceType serviceType) {
        this(serviceType.name);
    }

    @Override
    public Class handlerClass() {
        return Handler.class;
    }

    @Override
    public void accept(Handler handler, MessageConnection connection) {
        handler.handle(this, connection);
    }

    @Override
    public String toString() {
        return "SshMsgServiceAccept {"
                + "serviceName='" + this.serviceName + '\''
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

        void handle(SshMsgServiceAccept message, MessageConnection connection);

    }
}
