This commit is contained in:
NIGGER SLAYER 2026-04-16 16:33:53 +08:00
commit 3088dff966
3 changed files with 43 additions and 29 deletions

View File

@ -142,6 +142,7 @@ class RealTimeCommunicationManager extends ChangeNotifier {
var rtcToken = await SCAccountRepository().getRtcToken(
currenRoom?.roomProfile?.roomProfile?.id ?? "",
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
isPublisher: isOnMai(),
);
engine?.renewToken(rtcToken.rtcToken ?? "");
},
@ -151,6 +152,7 @@ class RealTimeCommunicationManager extends ChangeNotifier {
var rtcToken = await SCAccountRepository().getRtcToken(
currenRoom?.roomProfile?.roomProfile?.id ?? "",
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
isPublisher: false,
);
await engine?.joinChannel(
token: rtcToken.rtcToken ?? "",

View File

@ -67,7 +67,11 @@ abstract class SocialChatUserRepository {
Future anchorHeartbeat(String roomId);
///token
Future<SCRtcTokenRes> getRtcToken(String channel, String userId);
Future<SCRtcTokenRes> getRtcToken(
String channel,
String userId, {
bool isPublisher = false,
});
///退
Future<bool> quitRoom(String roomId);

View File

@ -211,10 +211,18 @@ class SCAccountRepository implements SocialChatUserRepository {
///external/im-trtc/tmp/agora/sig
@override
Future<SCRtcTokenRes> getRtcToken(String channel, String userId) async {
Future<SCRtcTokenRes> getRtcToken(
String channel,
String userId, {
bool isPublisher = false,
}) async {
final result = await http.get(
"2572c69d25a0946b0cb35b24bdfcd61c9bcef4afdaced7dfc47a641bd9584f96",
queryParams: {"channelName": channel, "userId": userId},
queryParams: {
"channelName": channel,
"userId": userId,
"isPublisher": isPublisher,
},
fromJson: (json) => SCRtcTokenRes.fromJson(json),
);
return result;