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

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

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

/**
 * @author Alex Usun
 */
public class SshMsgGlobalRequestUnknown
        extends SshMsgGlobalRequest<SshMsgGlobalRequestUnknown.Handler> {

    public final String requestName;
    public final byte[] data;

    public SshMsgGlobalRequestUnknown(String requestName, boolean wantReply, byte[] data) {
        super(wantReply);

        assertNotNull(requestName);
        this.requestName = requestName;

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

    @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 "SshMsgGlobalRequestUnknown {"
               + "requestName='" + this.requestName + '\''
               + ", wantReply=" + this.wantReply
               + ", data=" + HexFormat.formatData(this.data)
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
