package com.jscape.inet.protocol;

import com.jscape.util.event.EventHandler;

/**
 * @author Alex Usun
 */
public class SendMessageRequest
        extends AbstractSessionRequest {

    private final Message message;

    public SendMessageRequest(Session session, Message message) {
        super(session);

        this.message = message;
    }

    public Message getMessage() {
        return this.message;
    }

    public void setHandled() {
        super.setHandled();
    }

    public SendMessageRequest fire() {
        iterateHandlers();
        assertHandled();
        return this;
    }

    protected void accept(EventHandler handler) {
        ((Handler) handler).handle(this);
    }

    public interface Handler
            extends EventHandler {

        void handle(SendMessageRequest request);

    }

}
