sendRequest method
inviting hosts for a PK.
you will need to specify the targetHostIDs
you want to connect with.
Remember the hosts you invite must has started a live stream,
otherwise, an error will return via the method you called.
you can used timeout
to set the timeout duration of the PK battle
request you sent. After it timed out, the host who sent the request
will receive a callback notification via the ZegoLiveStreamingPKEvents.onOutgoingRequestTimeout.
if you want to customize the info that you want the host you invited to
receive, you can set customData
, and the invited host will receive
via ZegoLiveStreamingPKEvents.onIncomingRequestReceived.
If you want the remote host to directly accept without a confirmation
dialog before entering the PK, you can set isAutoAccept
to true.
Please note that within the same PK session, this value ONLY takes
effect the FIRST time it is set (after the first acceptance of the
invitation), subsequent invitations will use the value set during the
first acceptance.
Implementation
Future<ZegoLiveStreamingPKServiceSendRequestResult> sendRequest({
required List<String> targetHostIDs,
int timeout = 60,
String customData = '',
bool isAutoAccept = false,
}) async {
ZegoLoggerService.logInfo(
'targetHostIDs:$targetHostIDs, '
'timeout:$timeout, '
'customData:$customData, '
'isAutoAccept:$isAutoAccept, ',
tag: 'live-streaming',
subTag: 'controller.pk, sendRequest',
);
return ZegoUIKitPrebuiltLiveStreamingPK.instance.sendPKBattleRequest(
targetHostIDs: targetHostIDs,
timeout: timeout,
customData: customData,
isAutoAccept: isAutoAccept,
);
}