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

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

/**
 * @author Alex Usun
 */
public class SshMsgChannelRequestWindowChange
        extends SshMsgChannelRequest<SshMsgChannelRequestWindowChange.Handler> {

    public final int terminalCharactersWidth;
    public final int terminalRowsHeight;
    public final int terminalPixelsWidth;
    public final int terminalPixelsHeight;

    public SshMsgChannelRequestWindowChange(int recipientChannel,
                                            int terminalCharactersWidth,
                                            int terminalRowsHeight,
                                            int terminalPixelsWidth,
                                            int terminalPixelsHeight) {
        super(recipientChannel, false);

        this.terminalCharactersWidth = terminalCharactersWidth;
        this.terminalRowsHeight = terminalRowsHeight;
        this.terminalPixelsWidth = terminalPixelsWidth;
        this.terminalPixelsHeight = terminalPixelsHeight;
    }

    @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 "SshMsgChannelRequestWindowChange {"
                + "recipientChannel=" + this.recipientChannel
                + ", wantReply=" + this.wantReply
                + ", terminalCharactersWidth=" + this.terminalCharactersWidth
                + ", terminalRowsHeight=" + this.terminalRowsHeight
                + ", terminalPixelsWidth=" + this.terminalPixelsWidth
                + ", terminalPixelsHeight=" + this.terminalPixelsHeight
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
