Administrator
5 days ago e2dd80eec7df85a422d11338ca9dfdb869782a79
src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/AbstractPrivateChannelHandler.java
@@ -11,22 +11,7 @@
import java.nio.charset.StandardCharsets;
/**
 * 私有频道处理器的抽象基类。
 *
 * <h3>封装内容</h3>
 * <ul>
 *   <li>HMAC-SHA512 签名计算(UTF-8 编码)</li>
 *   <li>认证请求 JSON 构建(id/time/channel/payload/auth)</li>
 *   <li>subscribe / unsubscribe 的默认实现(含签名)</li>
 *   <li>用户 ID 获取(从 {@link GateGridTradeService#getUserId()})</li>
 * </ul>
 *
 * <h3>签名算法</h3>
 * {@code SIGN = Hex(HmacSHA512(secret_utf8, "channel={channel}&event={event}&time={timeSec}"_utf8))}
 *
 * <h3>子类</h3>
 * {@link com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionsChannelHandler}、
 * {@link com.xcong.excoin.modules.gateApi.wsHandler.handler.PositionClosesChannelHandler}
 * 私有频道 WS 处理器的抽象基类,封装 HMAC-SHA512 签名认证与订阅/取消订阅逻辑。
 *
 * @author Administrator
 */
@@ -40,6 +25,8 @@
    protected final String apiSecret;
    private final String contract;
    private final GateGridTradeService gridTradeService;
    private volatile boolean subscribed = false;
    public AbstractPrivateChannelHandler(String channelName,
                                          String apiKey, String apiSecret,
@@ -180,4 +167,10 @@
            return "";
        }
    }
    @Override
    public boolean isSubscribed() { return subscribed; }
    @Override
    public void setSubscribed(boolean subscribed) { this.subscribed = subscribed; }
}