package com.cmvr.quic.contract;

import com.cmvr.quic.gateway.v1.MediaFrame;
import com.cmvr.quic.gateway.v1.NodeEvent;
import com.cmvr.quic.gateway.v1.NodeSnapshot;

import java.util.Collection;
import java.util.function.Consumer;

/** QUIC 模块与平台业务之间的进程内事件接口。 */
public interface QuicEventBus {

    Collection<NodeSnapshot> listNodes();

    Subscription watchNodes(boolean includeCurrent, Consumer<NodeEvent> listener);

    Subscription subscribeMedia(String nodeId, int trackId, int requestedCapacity,
                                Consumer<MediaFrame> listener);

    interface Subscription extends AutoCloseable {
        Subscription CLOSED = new Subscription() {
            @Override
            public void close() {
            }
        };

        @Override
        void close();
    }
}

