package com.sjyt.icom.asst.context.handle.srs;

import com.sjyt.icom.asst.common.event.SrsCallBackEvent;
import com.sjyt.icom.asst.context.handle.HandleContext;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * <p>Srs回调逻辑上下文</p>
 *
 * @author renyanru
 * @version V1.0.0
 * @date 2022/6/14 16:04
 */
@Component
@AllArgsConstructor
public class RtspHandleContext implements HandleContext<SrsCallBackEvent, Integer> {
    private final RtspAppHandle rtspAppHandle;
    private final RtspParamHandle rtspParamHandle;
    private final RtspFinallyHandle rtspFinallyHandle;

    /**
     * 所有链上下文需要实现此接口
     *
     * @param event e
     * @return r
     */
    @Override
    public Integer todo(SrsCallBackEvent event) {
        RtspHandle.Builder<SrsCallBackEvent, Integer> builder = new RtspHandle.Builder<>();
        builder.addHandler(rtspParamHandle)
                .addHandler(rtspAppHandle)
                .addHandler(rtspFinallyHandle);
        return builder.build().doChain(event);
    }
}
