iOS | Android | macOS | Windows | Electron | Web | Flutter |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
UserSig
(the room entry ticket), but also PrivateMapKey (the permission ticket). The latter contains an encrypted roomid
and permission bit list.UserSig
but not PrivateMapKey
will be unable to enter the specified room.PrivateMapKey
uses the eight bits of a byte to represent different permissions for users holding PrivateMapKey
.Bit Sequence | Binary | Decimal | Permission |
First | 0000 0001 | 1 | Room creation |
Second | 0000 0010 | 2 | Room entry |
Third | 0000 0100 | 4 | Sending audio |
Fourth | 0000 1000 | 8 | Receiving audio |
Fifth | 0001 0000 | 16 | Sending video |
Sixth | 0010 0000 | 32 | Receiving video |
Seventh | 0100 0000 | 64 | Sending substream (screen sharing) video |
Eighth | 1000 0000 | 128 | Receiving substream (screen sharing) video |
SDKAppid
), all users using the application must pass privateMapKey
in TRTCParams
to enter a room (as described in Step 2 below). Therefore, you are not advised to enable the feature if you have active users using the application.PrivateMapKey
on your serverPrivateMapKey
protects the client from being reverse engineered and cracked and consequently prevents non-members from entering high-level rooms. Therefore, instead of calculating PrivateMapKey
directly on your application, you should do so on your server and then return the result to your application.PrivateMapKey
calculation codes for Java, GO, PHP, Node.js. Python, C#, and C++. You can download and integrate them into your server.Programming Language | Key Functions | Download Link |
Java | genPrivateMapKey and genPrivateMapKeyWithStringRoomID | |
GO | GenPrivateMapKey and GenPrivateMapKeyWithStringRoomID | |
PHP | genPrivateMapKey and genPrivateMapKeyWithStringRoomID | |
Node.js | genPrivateMapKey and genPrivateMapKeyWithStringRoomID | |
Python | genPrivateMapKey and genPrivateMapKeyWithStringRoomID | |
C# | genPrivateMapKey and genPrivateMapKeyWithStringRoomID | |
C++ | genPrivateMapKey and genPrivateMapKeyWithStringRoomID |
PrivateMapKey
from your server to your applicationPrivateMapKey
is calculated on your server and distributed to your application, which can then pass the PrivateMapKey
to the SDK via two methods.PrivateMapKey
to the SDK when calling enterRoom
PrivateMapKey
when users enter a room. It is simple and is used to assign permissions to users before room entry.PrivateMapKey
to the SDK through an experimental APIPrivateMapKey
carried in TRTCParams
at the time of room entry. That means if you set a short validity period for PrivateMapKey
, such as 5 minutes, the re-verification may fail and cause the audience to be removed from the room when they switch to the role of “anchor”.switchRole
to switch to the role of “anchor”, apply for a new PrivateMapKey
from your server and update it to the SDK by calling the experimental API updatePrivateMapKey
. Below is the sample code:
JSONObject jsonObject = new JSONObject();try {jsonObject.put("api", "updatePrivateMapKey");JSONObject params = new JSONObject();params.put("privateMapKey", "xxxxx"); // Enter the new `privateMapKey`.jsonObject.put("params", params);mTRTCCloud.callExperimentalAPI(jsonObject.toString());} catch (JSONException e) {e.printStackTrace();}
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];[params setObject:@"xxxxx" forKey:@"privateMapKey"]; // Enter the new `privateMapKey`.NSDictionary *dic = @{@"api": @"updatePrivateMapKey", @"params": params};NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:0 error:NULL];NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];[WXTRTCCloud sharedInstance] callExperimentalAPI:jsonStr];
std::string api = "{\\"api\\":\\"updatePrivateMapKey\\",\\"params\\":{\\"privateMapKey\\":"xxxxx"}}";TRTCCloudCore::GetInstance()->getTRTCCloud()->callExperimentalAPI(api.c_str());
std::string api = "{\\"api\\":\\"updatePrivateMapKey\\",\\"params\\":{\\"privateMapKey\\":"xxxxx"}}";mTRTCCloud.callExperimentalAPI(api);
SDKAppid
), users must pass PrivateMapKey
in TRTCParams
to enter any room under the application. Therefore, if your online business is running, and you haven’t integrated into it the privateMapKey
logic, please do not enable room permission control.PrivateMapKey
and UserSig
?UserSig
is a required parameter of TRTCParams
, which is used to check whether the current user is authorized to use TRTC services and prevent attackers from stealing the traffic in your application (SDKAppid
).PrivateMapKey
is an optional parameter of TRTCParams
, which is used to check whether the current user is authorized to enter the specified room (roomid
) and confirm the user’s permissions in the room. Use PrivateMapKey
only if you need to distinguish users from one another.
Was this page helpful?