package com.xhkjedu.slive.utils.agora;

import com.xhkjedu.slive.config.ConfigKey;
import com.xhkjedu.utils.N_Utils;

public class TokenUtil {
    static String appId = ConfigKey.appId;
    static String appCertificate = ConfigKey.appCertificate;
    static int timestamp = ConfigKey.expirationTimeInSeconds;

    /**
     * 获取rtc token
     * @Param [uid(如果填 0，则表示不对 uid 鉴权), channelName]
     * @Author ywx
     * @Date 2021/1/25 13:28
     * @return java.lang.String
     **/
    public static String getRtcToken(int uid, String channelName) {
        RtcTokenBuilder token = new RtcTokenBuilder();
        int timestamp2 = N_Utils.getSecondTimestamp() + timestamp;
        String result = token.buildTokenWithUid(appId, appCertificate, channelName, uid, RtcTokenBuilder.Role.Role_Publisher, timestamp2);
        return result;
    }
}
