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

    public final String name;
    public final String value;

    public SshMsgChannelRequestEnv(int recipientChannel, boolean wantReply, String name, String value) {
        super(recipientChannel, wantReply);

        assertNotNull(name);
        this.name = name;

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

    @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 "SshMsgChannelRequestEnv {"
                + "recipientChannel=" + this.recipientChannel
                + ", wantReply=" + this.wantReply
                + ", name='" + this.name + '\''
                + ", value='" + this.value + '\''
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
