presenceChannel method

PresenceChannel presenceChannel(
  1. String channelName, {
  2. required EndpointAuthorizableChannelAuthorizationDelegate<PresenceChannelAuthorizationData> authorizationDelegate,
  3. bool forceCreateNewInstance = false,
})

Creates a private channel.

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

Example:

PresenceChannel myPresenceChannel = client.presenceChannel(
  'presence-channel',
  authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate
      .forPresenceChannel(
    authorizationEndpoint: Uri.parse('https://test.pusher.com/pusher/auth'),
    headers: const {},
  ),
 );

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);
/// ```
PresenceChannel presenceChannel(
  String channelName, {
  required EndpointAuthorizableChannelAuthorizationDelegate<
          PresenceChannelAuthorizationData>
      authorizationDelegate,
  bool forceCreateNewInstance = false,
}) {
  if (_isDisposed) {
    throw const PusherChannelsClientDisposedException();
  }
  return channelsManager.presenceChannel(
    channelName,
    authorizationDelegate: authorizationDelegate,
    forceCreateNewInstance: forceCreateNewInstance,
  );
}