hostAgreeCoHostRequest method
host approve the co-host request made by audience
.
@return A Future
that representing whether the request was successful.
Implementation
Future<bool> hostAgreeCoHostRequest(
ZegoUIKitUser audience, {
String customData = '',
}) async {
ZegoLoggerService.logInfo(
'audience:${audience.id}, customData:$customData, ',
tag: 'live-streaming-coHost',
subTag: 'controller, hostAgreeCoHostRequest',
);
if (null == private.hostManager ||
null == private.connectManager ||
null == private.prebuiltConfig) {
ZegoLoggerService.logInfo(
'params is not valid, can not agree, '
'hostManager:${private.hostManager}, '
'connectManager:${private.connectManager}, '
'prebuiltConfig:${private.prebuiltConfig}, ',
tag: 'live-streaming-coHost',
subTag: 'controller, hostAgreeCoHostRequest',
);
return false;
}
if (!private.isLocalHost) {
ZegoLoggerService.logInfo(
'local is not a host, can not agree',
tag: 'live-streaming-coHost',
subTag: 'controller, hostAgreeCoHostRequest',
);
return false;
}
if (private.connectManager!.coHostCount.value +
private.agreeRequestingUserIDs.length >=
private.connectManager!.maxCoHostCount) {
private.events?.coHost.onMaxCountReached
?.call(private.prebuiltConfig!.coHost.maxCoHostCount);
ZegoLoggerService.logInfo(
'co-host max count had reached, can not agree',
tag: 'live-streaming-coHost',
subTag: 'controller, hostAgreeCoHostRequest',
);
return false;
}
private.agreeRequestingUserIDs.add(audience.id);
ZegoLoggerService.logInfo(
'agree requesting count:${private.agreeRequestingUserIDs.length}',
tag: 'live-streaming-coHost',
subTag: 'controller, hostAgreeCoHostRequest',
);
return ZegoUIKit()
.getSignalingPlugin()
.acceptInvitation(
inviterID: audience.id,
data: customData,
)
.then((result) {
ZegoLoggerService.logInfo(
'agree the co-host request from ${audience.id}, result:$result',
tag: 'live-streaming-coHost',
subTag: 'controller, hostAgreeCoHostRequest',
);
if (result.error == null) {
private.events?.coHost.host.onActionAcceptRequest?.call();
private.connectManager!.removeRequestCoHostUsers(audience);
} else {
showDebugToast('error:${result.error}');
}
return result.error == null;
});
}