Tools
Tools copied to clipboard
ChatTokenBuilder2.java 部分注释有误,可能会误导用户
文件位置
https://github.com/AgoraIO/Tools/blob/dev/accesstoken2/DynamicKey/AgoraDynamicKey/java/src/main/java/io/agora/chat/ChatTokenBuilder2.java
问题
这里的注释有误,会造成误导。需要改动的地方已经使用 TODO
标记。
/**
* Build the CHAT user token.
*
* @param appId: The App ID issued to you by Agora. Apply for a new App ID from
* Agora Dashboard if it is missing from your kit. See Get an App ID.
* @param appCertificate: Certificate of the application that you registered in
* the Agora Dashboard. See Get an App Certificate.
* @param userId: The user's id, must be unique.
* optionalUid must be unique. //TODO 这里应该没有 optionalUid
* @param expire: represented by the number of seconds elapsed since now. If, for example, you want to access the
* Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
* @return The RTC token. //TODO 这里不是 RTC Token,而是 Chat 的 User Token
*/
public String buildUserToken(String appId, String appCertificate, String userId, int expire) {
AccessToken2 accessToken = new AccessToken2(appId, appCertificate, expire);
AccessToken2.Service serviceChat = new AccessToken2.ServiceChat(userId);
serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_USER, expire);
accessToken.addService(serviceChat);
try {
return accessToken.build();
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
/**
* Build the CHAT app token.
*
* @param appId: The App ID issued to you by Agora. Apply for a new App ID from
* Agora Dashboard if it is missing from your kit. See Get an App ID.
* @param appCertificate: Certificate of the application that you registered in
* the Agora Dashboard. See Get an App Certificate.
* @param expire: represented by the number of seconds elapsed since now. If, for example, you want to access the
* Agora Service within 10 minutes after the token is generated, set expireTimestamp as 600(seconds).
* @return The RTC token. //TODO 这里不是 RTC Token,而是 Chat 的 App Token
*/
public String buildAppToken(String appId, String appCertificate, int expire) {
AccessToken2 accessToken = new AccessToken2(appId, appCertificate, expire);
AccessToken2.Service serviceChat = new AccessToken2.ServiceChat();
serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_APP, expire);
accessToken.addService(serviceChat);
try {
return accessToken.build();
} catch (Exception e) {
e.printStackTrace();
return "";
}
}