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

import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author renyanru
 * @version V1.0.0
 * @date 2022/6/1 16:53
 */
@Component
public class WsFrameHandleContext {
  @Resource private BinaryWsFrameHandle binaryFrame;
  @Resource private CloseWsFrameHandle closeFrame;
  @Resource private PingWsFrameHandle pingFrame;
  @Resource private PongWsFrameHandle pongFrame;
  @Resource private TextWsFrameHandle textFrame;

  public void doSomeTing(WsFrameEvent wsFrameEvent) {
    WsFrameHandle.Builder<WsFrameEvent> builder = new WsFrameHandle.Builder<>();
    builder
        .addHandler(closeFrame)
        .addHandler(pingFrame)
        .addHandler(pongFrame)
        .addHandler(binaryFrame)
        .addHandler(textFrame);
    builder.build().doChain(wsFrameEvent);
  }
}
