subscribe method

  1. @override
void subscribe()
override

Unlike the public channels, this channel:

  1. Grabs the authorization data of type PrivateEncryptedChannelAuthorizationData.
  2. Sends the subscription event with the derived data.
  3. Shared secret is accessible from authData for further internal decryption of the event data.

See also:

Implementation

@override
void subscribe() async {
  super.subscribe();
  final fixatedLifeCycleCount = startNewAuthRequestCycle();
  await setAuthKeyFromDelegate();
  final currentAuthKey = authData?.authKey;
  if (fixatedLifeCycleCount < authRequestCycle ||
      currentAuthKey == null ||
      state?.status == ChannelStatus.unsubscribed) {
    return;
  }
  connectionDelegate.sendEvent(
    ChannelSubscribeEvent.forPrivateEncryptedChannel(
      channelName: name,
      authKey: currentAuthKey,
    ),
  );
}