001/*
002 * JGrapes Event Driven Framework
003 * Copyright (C) 2024 Michael N. Lipp
004 * 
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Affero General Public License as published by 
007 * the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 * 
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Affero General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jgrapes.io.util;
020
021import org.jgrapes.io.IOSubchannel;
022import org.jgrapes.io.events.OpenSocketConnection;
023import org.jgrapes.io.events.Output;
024import org.jgrapes.net.events.ClientConnected;
025
026/**
027 * May be used to associate (pending) {@link Output} events with another
028 * event. As an example consider readily available data (not to be produced
029 * lazily) that is to be emitted once a connection to a receiver has been
030 * established. In this case the {@link OpenSocketConnection} event may 
031 * be associated with an output supplier. The handler for the 
032 * {@link ClientConnected} event can then check if the 
033 * {@link OpenSocketConnection} event has an associated output supplier 
034 * and call the supplier's {@link OutputSupplier#emit} method. 
035 * 
036 * @since 2.9.0
037 */
038@FunctionalInterface
039public interface OutputSupplier {
040
041    /**
042     * Emit the {@link Output} events.
043     *
044     * @param channel the channel
045     */
046    void emit(IOSubchannel channel);
047
048}