PusherChannelsClient class
A centralized manager of connection and channel bindings.
Note
: If an instance of this class has been disposed -
it can't be reused. So if you want to use the instance after disposal -
you will have to create a new instance.
- Use PusherChannelsClient.websocket to create a client with PusherChannelsWebSocketConnection.
- Use PusherChannelsClient.custom to create a client with your own implementation of PusherChannelsConnection.
Enables:
- Creating channels: publicChannel, privateChannel, presenceChannel.
- Listening for all events through eventStream.
- Listening for
pusher:error
events through pusherErrorEventStream. - Listening for the lifecycle state changes through lifecycleStream.
- Listening for connection/reconnection establishment onConnectionEstablished.
Constructors
- PusherChannelsClient.custom({required PusherChannelsConnectionDelegate connectionDelegate, required PusherChannelsClientLifeCycleConnectionErrorHandler connectionErrorHandler, Duration minimumReconnectDelayDuration = const Duration(seconds: 1), Duration defaultActivityDuration = kPusherChannelsDefaultActivityDuration, Duration? activityDurationOverride, Duration waitForPongDuration = kPusherChannelsDefaultWaitForPongDuration})
-
Providing a client with a delegate returning custom implementation of PusherChannelsConnection.
Parameters:
factory
- PusherChannelsClient.websocket({required PusherChannelsOptions options, required PusherChannelsClientLifeCycleConnectionErrorHandler connectionErrorHandler, Duration minimumReconnectDelayDuration = const Duration(seconds: 1), Duration defaultActivityDuration = kPusherChannelsDefaultActivityDuration, Duration? activityDurationOverride, Duration waitForPongDuration = kPusherChannelsDefaultWaitForPongDuration})
-
Providing a client with a delegate returning PusherChannelsWebSocketConnection.
Parameters:
factory
Properties
- channelsManager → ChannelsManager
-
final
- controller → PusherChannelsClientLifeCycleController
-
final
-
eventStream
→ Stream<
PusherChannelsReadEvent> -
Used to listen for all the events received from a server.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
no setter
-
lifecycleStream
→ Stream<
PusherChannelsClientLifeCycleState> -
Used to listen for the lifecycle changes of the controller.
For exmaple, when this client connects, reconnects, disconnects, pending connection an e.t.c.
See PusherChannelsClientLifeCycleState for more details.
no setter
-
onConnectionEstablished
→ Stream<
void> -
Used to listen on whenever the client manages to establish connection
receiving the event with name
pusher:connection_established
no setter -
pusherErrorEventStream
→ Stream<
PusherChannelsReadEvent> -
Used to listen for events with name
pusher:error
.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
) → Future< void> - Connects to a server via controller.
-
disconnect(
) → Future< void> - Disconnects from a server via controller.
-
dispose(
) → void - Destroys controller and channelsManager making this instance unusable.
-
getConnectionCompleterFuture(
) → Future< void> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
presenceChannel(
String channelName, {required EndpointAuthorizableChannelAuthorizationDelegate< PresenceChannelAuthorizationData> authorizationDelegate, bool forceCreateNewInstance = false}) → PresenceChannel - Creates a private channel.
-
privateChannel(
String channelName, {required EndpointAuthorizableChannelAuthorizationDelegate< PrivateChannelAuthorizationData> authorizationDelegate, bool forceCreateNewInstance = false}) → PrivateChannel - Creates a private channel.
-
privateEncryptedChannel(
String channelName, {required EndpointAuthorizableChannelAuthorizationDelegate< PrivateEncryptedChannelAuthorizationData> authorizationDelegate, bool forceCreateNewInstance = false, PrivateEncryptedChannelEventDataEncodeDelegate eventDataEncodeDelegate = PrivateEncryptedChannel.defaultEventDataEncoder}) → PrivateEncryptedChannel - Creates a private encrypted channel.
-
publicChannel(
String channelName, {bool forceCreateNewInstance = false}) → PublicChannel - Creates a public channel.
-
reconnect(
) → Future< void> - Reconnects to a server via controller.
-
sendEvent(
PusherChannelsSentEventMixin event) → void -
Sends the
event
to a server. -
toString(
) → String -
A string representation of this object.
inherited
-
trigger(
PusherChannelsTriggerEvent event) → void -
Triggers the
event
to a server.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited