privateEncryptedChannel method

PrivateEncryptedChannel privateEncryptedChannel(
  1. String channelName, {
  2. required EndpointAuthorizableChannelAuthorizationDelegate<PrivateEncryptedChannelAuthorizationData> authorizationDelegate,
  3. bool forceCreateNewInstance = false,
  4. PrivateEncryptedChannelEventDataEncodeDelegate eventDataEncodeDelegate = PrivateEncryptedChannel.defaultEventDataEncoder,
})

Creates a private encrypted channel.

Usage is the same as with the private channels but note that your server side has to support the encrypted channels feature.

Example:

  PrivateEncryptedChannel myEncryptedChannel = client.privateEncryptedChannel(
  'private-encrypted-channel',
  authorizationDelegate:
      EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateEncryptedChannel(
    authorizationEndpoint: Uri.parse('https://test.pusher.com/pusher/auth'),
    headers: const {},
  ),
);

Provide your implementation of EndpointAuthorizableChannelAuthorizationDelegate or you may use: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateEncryptedChannel

You may provide your own delegate function to encode the decrypted message into the plain text by providing eventDataEncodeDelegate. Otherwise the default one will be used. Example:

...
eventDataEncodeDelegate: (Uint8List bytes) => utf8.decode(bytes),
...

Note: if forceCreateNewInstance is true then this client will return a new instance each time this method is called instead of giving an internally linked one.

Example:

var oldVariable = client.publicChannel('hello');
var newVariable = client.publicChannel('hello');
// prints true
print(oldVariable == newVariable);
var newestVariable = client.publicChannel(
  'hello',
  forceCreateNewInstance: true,
// prints false
print(newestVariable == oldVariable || newestVariable == newVariable);

Implementation

/// var newestVariable = client.publicChannel(
///   'hello',
///   forceCreateNewInstance: true,
// );

/// // prints false
/// print(newestVariable == oldVariable || newestVariable == newVariable);
/// ```
PrivateEncryptedChannel privateEncryptedChannel(
  String channelName, {
  required EndpointAuthorizableChannelAuthorizationDelegate<
          PrivateEncryptedChannelAuthorizationData>
      authorizationDelegate,
  bool forceCreateNewInstance = false,
  PrivateEncryptedChannelEventDataEncodeDelegate eventDataEncodeDelegate =
      PrivateEncryptedChannel.defaultEventDataEncoder,
}) =>
    channelsManager.privateEncryptedChannel(
      channelName,
      authorizationDelegate: authorizationDelegate,
      forceCreateNewInstance: forceCreateNewInstance,
      eventDataEncodeDelegate: eventDataEncodeDelegate,
    );