修复rtc
This commit is contained in:
parent
b076e43180
commit
144cfc8e22
@ -135,23 +135,25 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
|||||||
onUserOffline: (connection, remoteUid, reason) {
|
onUserOffline: (connection, remoteUid, reason) {
|
||||||
print('rtc用户 $remoteUid 离开了频道 (原因: ${reason})');
|
print('rtc用户 $remoteUid 离开了频道 (原因: ${reason})');
|
||||||
},
|
},
|
||||||
onTokenPrivilegeWillExpire: (
|
onTokenPrivilegeWillExpire: (
|
||||||
RtcConnection connection,
|
RtcConnection connection,
|
||||||
String token,
|
String token,
|
||||||
) async {
|
) async {
|
||||||
var rtcToken = await SCAccountRepository().getRtcToken(
|
var rtcToken = await SCAccountRepository().getRtcToken(
|
||||||
currenRoom?.roomProfile?.roomProfile?.id ?? "",
|
currenRoom?.roomProfile?.roomProfile?.id ?? "",
|
||||||
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
|
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
|
||||||
);
|
isPublisher: isOnMai(),
|
||||||
engine?.renewToken(rtcToken.rtcToken ?? "");
|
);
|
||||||
},
|
engine?.renewToken(rtcToken.rtcToken ?? "");
|
||||||
|
},
|
||||||
onAudioVolumeIndication: initializeAudioVolumeIndicationCallback,
|
onAudioVolumeIndication: initializeAudioVolumeIndicationCallback,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
var rtcToken = await SCAccountRepository().getRtcToken(
|
var rtcToken = await SCAccountRepository().getRtcToken(
|
||||||
currenRoom?.roomProfile?.roomProfile?.id ?? "",
|
currenRoom?.roomProfile?.roomProfile?.id ?? "",
|
||||||
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
|
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
|
||||||
);
|
isPublisher: false,
|
||||||
|
);
|
||||||
await engine?.joinChannel(
|
await engine?.joinChannel(
|
||||||
token: rtcToken.rtcToken ?? "",
|
token: rtcToken.rtcToken ?? "",
|
||||||
channelId: currenRoom?.roomProfile?.roomProfile?.id ?? "",
|
channelId: currenRoom?.roomProfile?.roomProfile?.id ?? "",
|
||||||
|
|||||||
@ -63,11 +63,15 @@ abstract class SocialChatUserRepository {
|
|||||||
///发送心跳
|
///发送心跳
|
||||||
Future heartbeat(String status, bool upMick, {String? roomId});
|
Future heartbeat(String status, bool upMick, {String? roomId});
|
||||||
|
|
||||||
///上麦心跳
|
///上麦心跳
|
||||||
Future anchorHeartbeat(String roomId);
|
Future anchorHeartbeat(String roomId);
|
||||||
|
|
||||||
///声网token
|
///声网token
|
||||||
Future<SCRtcTokenRes> getRtcToken(String channel, String userId);
|
Future<SCRtcTokenRes> getRtcToken(
|
||||||
|
String channel,
|
||||||
|
String userId, {
|
||||||
|
bool isPublisher = false,
|
||||||
|
});
|
||||||
|
|
||||||
///退出房间
|
///退出房间
|
||||||
Future<bool> quitRoom(String roomId);
|
Future<bool> quitRoom(String roomId);
|
||||||
|
|||||||
@ -209,16 +209,24 @@ class SCAccountRepository implements SocialChatUserRepository {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
///external/im-trtc/tmp/agora/sig
|
///external/im-trtc/tmp/agora/sig
|
||||||
@override
|
@override
|
||||||
Future<SCRtcTokenRes> getRtcToken(String channel, String userId) async {
|
Future<SCRtcTokenRes> getRtcToken(
|
||||||
final result = await http.get(
|
String channel,
|
||||||
"2572c69d25a0946b0cb35b24bdfcd61c9bcef4afdaced7dfc47a641bd9584f96",
|
String userId, {
|
||||||
queryParams: {"channelName": channel, "userId": userId},
|
bool isPublisher = false,
|
||||||
fromJson: (json) => SCRtcTokenRes.fromJson(json),
|
}) async {
|
||||||
);
|
final result = await http.get(
|
||||||
return result;
|
"2572c69d25a0946b0cb35b24bdfcd61c9bcef4afdaced7dfc47a641bd9584f96",
|
||||||
}
|
queryParams: {
|
||||||
|
"channelName": channel,
|
||||||
|
"userId": userId,
|
||||||
|
"isPublisher": isPublisher,
|
||||||
|
},
|
||||||
|
fromJson: (json) => SCRtcTokenRes.fromJson(json),
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
///live/room/quit
|
///live/room/quit
|
||||||
@override
|
@override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user