Skip to content

Commit 870ba17

Browse files
authored
Merge pull request #10 from yutingzeng/master
feat: 增加使用字符串房间号生成privateMapKey
2 parents b96120c + 867094e commit 870ba17

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@ public byte[] genUserBuf(String account, long dwAuthID, long dwExpTime,
172172
int roomStrLength = RoomStr.length();
173173
int offset = 0;
174174
int bufLength = 1 + 2 + accountLength + 20 ;
175+
if (roomStrLength > 0) {
176+
bufLength = bufLength + 2 + roomStrLength;
177+
}
175178
byte[] userbuf = new byte[bufLength];
176179

177180
//cVer
178181
if (roomStrLength > 0) {
179-
bufLength = bufLength + 2 + roomStrLength;
180182
userbuf[offset++] = 1;
181183
} else {
182184
userbuf[offset++] = 0;

src/test/com/tencentyun/TLSSigAPITest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public void testGenSigWithUserBug() {
3636
TLSSigAPIv2 api = new TLSSigAPIv2(1400000000, "5bd2850fff3ecb11d7c805251c51ee463a25727bddc2385f3fa8bfee1bb93b5e");
3737
System.out.println(api.genPrivateMapKey("xiaojun", 180 * 86400, 10000, 255));
3838
}
39+
//使用userbuf和字符串房间号生产privatemapkey
40+
@Test
41+
public void testGenSigWithUserBug() {
42+
TLSSigAPIv2 api = new TLSSigAPIv2(1400000000, "5bd2850fff3ecb11d7c805251c51ee463a25727bddc2385f3fa8bfee1bb93b5e");
43+
System.out.println(api.genPrivateMapKeyWithStringRoomID("xiaojun", 180 * 86400, "100000000", 255));
44+
}
3945

4046
/**
4147
* Method: hmacsha256(String identifier, long currTime, long expire)

tls-sig-api-v2-java.iml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager">
4+
<output url="file://$MODULE_DIR$/bin" />
5+
<exclude-output />
6+
<content url="file://$MODULE_DIR$" />
7+
<orderEntry type="sourceFolder" forTests="false" />
8+
</component>
9+
</module>

0 commit comments

Comments
 (0)