Skip to content

Commit 7ca86fc

Browse files
author
yutingzeng
committed
修改userbuf过期时间:时间戳+有效时间,与后台对齐
1 parent e62d6b8 commit 7ca86fc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/com/tencentyun/TLSSigAPIv2.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ private String genSig(String identifier, long expire, byte[] userbuf) {
8484
* @param dwSdkappid sdkappid
8585
* @param dwAuthID 数字房间号
8686
* @param dwExpTime 过期时间:该权限加密串的过期时间,超时时间内拿到该签名,并且发起进房间操作,时间为有效期
87+
* 实际填入userBuf为:expire,过期时间,当前时间 + 有效期(单位:秒)
8788
* @param dwPrivilegeMap 用户权限,255表示所有权限,主播0xff,观众0xab
8889
* @param dwAccountType 用户类型,默认为0
8990
* @return byte[] userbuf
@@ -129,11 +130,13 @@ public byte[] genUserBuf(String account ,long dwAuthID, long dwExpTime ,
129130
userbuf[offset++] = (byte)((dwAuthID & 0x0000FF00) >> 8);
130131
userbuf[offset++] = (byte)(dwAuthID & 0x000000FF);
131132

132-
//dwExpTime,过期时间
133-
userbuf[offset++] = (byte)((dwExpTime & 0xFF000000) >> 24);
134-
userbuf[offset++] = (byte)((dwExpTime & 0x00FF0000) >> 16);
135-
userbuf[offset++] = (byte)((dwExpTime & 0x0000FF00) >> 8);
136-
userbuf[offset++] = (byte)(dwExpTime & 0x000000FF);
133+
//expire,过期时间,当前时间 + 有效期(单位:秒)
134+
long currTime = System.currentTimeMillis()/1000;
135+
long expire = currTime + dwExpTime;
136+
userbuf[offset++] = (byte)((expire & 0xFF000000) >> 24);
137+
userbuf[offset++] = (byte)((expire & 0x00FF0000) >> 16);
138+
userbuf[offset++] = (byte)((expire & 0x0000FF00) >> 8);
139+
userbuf[offset++] = (byte)(expire & 0x000000FF);
137140

138141
//dwPrivilegeMap,权限位
139142
userbuf[offset++] = (byte)((dwPrivilegeMap & 0xFF000000) >> 24);

0 commit comments

Comments
 (0)