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 SshMsgChannelRequestSignal
        extends SshMsgChannelRequest<SshMsgChannelRequestSignal.Handler> {

    public final String signalName;

    public SshMsgChannelRequestSignal(int recipientChannel, String signalName) {
        super(recipientChannel, false);

        assertNotNull(signalName);
        this.signalName = signalName;
    }

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

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

    @Override
    public String toString() {
        return "SshMsgChannelRequestSignal {"
                + "recipientChannel=" + this.recipientChannel
                + ", wantReply=" + this.wantReply
                + ", signalName='" + this.signalName + '\''
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

        void handle(SshMsgChannelRequestSignal message, MessageConnection<Message> connection);

    }
}
