@@ -83,22 +83,22 @@ private String genSig(String identifier, long expire, byte[] userbuf) {
8383 * @param account 用户名
8484 * @param dwSdkappid sdkappid
8585 * @param dwAuthID 数字房间号
86- * @param dwExpTime 过期时间:该权限加密串的过期时间,建议300秒,300秒内拿到该签名, 并且发起进房间操作
87- * @param dwPrivilegeMap 用户权限,255表示所有权限
86+ * @param dwExpTime 过期时间:该权限加密串的过期时间,超时时间内拿到该签名, 并且发起进房间操作,时间为有效期
87+ * @param dwPrivilegeMap 用户权限,255表示所有权限,主播0xff,观众0xab
8888 * @param dwAccountType 用户类型,默认为0
8989 * @return byte[] userbuf
9090 */
9191 public byte [] genUserBuf (String account ,long dwAuthID , long dwExpTime ,
9292 long dwPrivilegeMap ,long dwAccountType ){
93- //视频校验位需要用到的字段
93+ //视频校验位需要用到的字段,按照网络字节序放入buf中
9494 /*
9595 cVer unsigned char/1 版本号,填0
9696 wAccountLen unsigned short /2 第三方自己的帐号长度
97- buffAccount wAccountLen 第三方自己的帐号字符
97+ account wAccountLen 第三方自己的帐号字符
9898 dwSdkAppid unsigned int/4 sdkappid
99- dwRoomId unsigned int/4 群组号码
100- dwExpTime unsigned int/4 过期时间 (当前时间 + 有效期(单位:秒,建议300秒))
101- dwPrivilegeMap unsigned int/4 权限位
99+ dwAuthID unsigned int/4 群组号码
100+ dwExpTime unsigned int/4 过期时间 ,直接使用填入的值
101+ dwPrivilegeMap unsigned int/4 权限位,主播0xff,观众0xab
102102 dwAccountType unsigned int/4 第三方帐号类型
103103 */
104104 int accountLength = account .length ();
@@ -112,7 +112,7 @@ public byte[] genUserBuf(String account ,long dwAuthID, long dwExpTime ,
112112 userbuf [offset ++] = (byte )((accountLength & 0xFF00 ) >> 8 );
113113 userbuf [offset ++] = (byte )(accountLength & 0x00FF );
114114
115- //buffAccount
115+ //account
116116 for (; offset < 3 + accountLength ; ++offset ) {
117117 userbuf [offset ] = (byte )account .charAt (offset - 3 );
118118 }
@@ -123,25 +123,25 @@ public byte[] genUserBuf(String account ,long dwAuthID, long dwExpTime ,
123123 userbuf [offset ++] = (byte )((sdkappid & 0x0000FF00 ) >> 8 );
124124 userbuf [offset ++] = (byte )(sdkappid & 0x000000FF );
125125
126- //dwAuthId
126+ //dwAuthId,房间号
127127 userbuf [offset ++] = (byte )((dwAuthID & 0xFF000000 ) >> 24 );
128128 userbuf [offset ++] = (byte )((dwAuthID & 0x00FF0000 ) >> 16 );
129129 userbuf [offset ++] = (byte )((dwAuthID & 0x0000FF00 ) >> 8 );
130130 userbuf [offset ++] = (byte )(dwAuthID & 0x000000FF );
131131
132- //dwExpTime
132+ //dwExpTime,过期时间
133133 userbuf [offset ++] = (byte )((dwExpTime & 0xFF000000 ) >> 24 );
134134 userbuf [offset ++] = (byte )((dwExpTime & 0x00FF0000 ) >> 16 );
135135 userbuf [offset ++] = (byte )((dwExpTime & 0x0000FF00 ) >> 8 );
136136 userbuf [offset ++] = (byte )(dwExpTime & 0x000000FF );
137137
138- //dwPrivilegeMap
138+ //dwPrivilegeMap,权限位
139139 userbuf [offset ++] = (byte )((dwPrivilegeMap & 0xFF000000 ) >> 24 );
140140 userbuf [offset ++] = (byte )((dwPrivilegeMap & 0x00FF0000 ) >> 16 );
141141 userbuf [offset ++] = (byte )((dwPrivilegeMap & 0x0000FF00 ) >> 8 );
142142 userbuf [offset ++] = (byte )(dwPrivilegeMap & 0x000000FF );
143143
144- //dwAccountType
144+ //dwAccountType,账户类型
145145 userbuf [offset ++] = (byte )((dwAccountType & 0xFF000000 ) >> 24 );
146146 userbuf [offset ++] = (byte )((dwAccountType & 0x00FF0000 ) >> 16 );
147147 userbuf [offset ++] = (byte )((dwAccountType & 0x0000FF00 ) >> 8 );
@@ -154,7 +154,8 @@ public String genSig(String identifier, long expire) {
154154 return genSig (identifier , expire , null );
155155 }
156156
157- public String genSigWithUserBuf (String identifier , long expire , byte [] userbuf ) {
157+ public String genSigWithUserBuf (String identifier , long expire ) {
158+ byte [] userbuf = genUserBuf (identifier ,1000 ,expire ,255 ,0 ); //生成userbuf
158159 return genSig (identifier , expire , userbuf );
159160 }
160161}
0 commit comments