secureChannel method

void secureChannel({
  1. required String channel,
  2. required String secret,
  3. Map<String, dynamic> metadata = const {},
})

Implementation

void secureChannel(
    {required String channel,
    required String secret,
    Map<String, dynamic> metadata = const {}}) {
  if (!connected()) {
    waitingTopicAuths.add(WaitingTopicAuth(channel, secret, metadata));
  } else {
    phoenixChannel!.push("create_channel", {
      "channel_id": channel,
      'secret': ChaCha20(loggedInUser.getPersonalKey())
          .encrypt(secret, Nonce.fromString('secret-$channel')),
      'metadata': PayloadCipher.encodePayload(metadata,
          nonce: Nonce.fromString(channel),
          chaCha20: ChaCha20(loggedInUser.getPersonalKey()))
    });
  }
}