FakeRealtimeClient class
A comprehensive test double for RealtimeClient to enable robust unit and widget testing of blocs, controllers, and services without requiring real socket servers or network connections.
Ships in package:baaba_realtime_client/testing.dart.
- Implemented types
Constructors
Properties
- abandonedInvocationCount → int
-
Timed-out invocations whose bookkeeping the underlying hub still holds.
no setteroverride
-
activeRooms
→ Set<
String> -
Set of currently active rooms joined by this client.
no setteroverride
- appPausedCount ↔ int
-
How many times notifyAppPaused has been called.
getter/setter pair
- appResumedCount ↔ int
-
How many times notifyAppResumed has been called.
getter/setter pair
-
chatStream
→ Stream<
ChatMessage> -
Stream of incoming chat messages (listening by default to
ReceiveMessageandChatMessage).no setteroverride - connectionId → String?
-
The active connection ID, if assigned by the server.
no setteroverride
-
errorStream
→ Stream<
RealtimeFailure> -
Broadcast stream of every failure the client observes, including ones with
no caller to return them to: a background reconnect that failed, a dropped
socket, a parse error on a typed stream.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConnected → bool
-
Whether the client is currently connected and able to send/receive messages.
no setteroverride
- isConnecting → bool
-
Whether the client is currently in an initial connection attempt.
no setteroverride
- isDisconnected → bool
-
Whether the client is disconnected.
no setteroverride
- isReconnecting → bool
-
Whether the client is attempting to reconnect following a connection drop.
no setteroverride
- lastFailure → RealtimeFailure?
-
The most recent failure, or null if nothing has gone wrong yet.
no setteroverride
-
messageStream
→ Stream<
RealtimeMessage> -
Broadcast stream of all incoming real-time messages, whatever their target
and whether or not anything is subscribed to it.
no setteroverride
- pendingInvocationCount → int
-
Invocations written to the wire that have not yet been answered.
no setteroverride
-
presenceStream
→ Stream<
UserPresence> -
Stream of incoming user presence updates (listening by default to
UserPresenceChanged).no setteroverride -
recordedInvocations
→ List<
Map< String, dynamic> > -
List of all recorded RPC invocations made via invoke or invokeAs.
no setter
-
recordedSends
→ List<
Map< String, dynamic> > -
List of all fire-and-forget messages sent via send.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
signalingStream
→ Stream<
SignalingMessage> -
Stream of incoming WebRTC signaling messages (listening by default to
ReceiveSignaling).no setteroverride - state → RealtimeConnectionState
-
Current connection lifecycle state.
no setteroverride
-
stateStream
→ Stream<
RealtimeConnectionState> -
Stream emitting connection state transitions.
no setteroverride
-
typingStream
→ Stream<
TypingIndicator> -
Stream of incoming typing indicators (listening by default to
UserTyping).no setteroverride
Methods
-
connect(
) → Future< Either< RealtimeFailure, Unit> > -
Establishes the real-time connection and completes protocol handshake.
override
-
disconnect(
) → Future< Either< RealtimeFailure, Unit> > -
Gracefully disconnects from the server.
override
-
dispose(
) → Future< void> -
Disconnects and releases every stream this client owns.
override
-
invoke(
String methodName, {List? args, Duration? timeout}) → Future< Either< RealtimeFailure, dynamic> > -
Invocates a hub or server RPC method and awaits a response.
override
-
invokeAs<
T> (String methodName, {required T parser(dynamic json), List? args, Duration? timeout}) → Future< Either< RealtimeFailure, T> > -
Invocates a hub method and parses the response into type
Tusingparser.override -
joinRoom(
Object roomName, {String joinMethod = 'JoinRoom'}) → Future< Either< RealtimeFailure, Unit> > -
Joins a chat room, channel, or video call group.
override
-
leaveRoom(
Object roomName, {String leaveMethod = 'LeaveRoom'}) → Future< Either< RealtimeFailure, Unit> > -
Leaves a chat room, channel, or video call group.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyAppPaused(
) → void -
Records that the app has been backgrounded.
override
-
notifyAppResumed(
) → void -
Reconciles the connection after the app returns to the foreground.
override
-
off(
String eventName) → void -
Unregisters all listeners for
eventName.override -
on(
String eventName) → Stream -
Listens to events broadcast under
eventName, delivering the event's first argument.override -
onArgs(
String eventName) → Stream< List> -
Listens to events broadcast under
eventName, delivering the full argument list exactly as the server sent it.override -
onAs<
T> (String eventName, {required T parser(dynamic json)}) → Stream< T> -
Listens to events broadcasted under
eventNameand parses them withparser.override -
reset(
) → void -
Clears recorded calls and active event controllers.
override
-
send(
String methodName, {List? args}) → Future< Either< RealtimeFailure, Unit> > -
Sends a fire-and-forget message or event without awaiting a return value.
override
-
sendChatMessage(
ChatMessage message, {String target = 'SendMessage'}) → Future< Either< RealtimeFailure, Unit> > -
Convenience API to dispatch a ChatMessage.
override
-
sendSignaling(
SignalingMessage message, {String target = 'SendSignaling'}) → Future< Either< RealtimeFailure, Unit> > -
Convenience API to transmit a WebRTC signaling message (offer, answer, ICE candidate, etc.).
override
-
sendTyping(
String room, {required bool isTyping, String target = 'SendTyping'}) → Future< Either< RealtimeFailure, Unit> > -
Convenience API to broadcast typing state in a room.
override
-
simulateChatMessage(
ChatMessage message) → void - Simulates an incoming chat message.
-
simulateError(
RealtimeFailure failure) → void -
Simulates a failure reaching errorStream and
RealtimeObserver.onError. -
simulateEvent(
String eventName, dynamic payload) → void - Simulates an incoming server event or broadcast.
-
simulateInvocationCounts(
{int pending = 0, int abandoned = 0}) → void - Sets the counts reported by pendingInvocationCount and abandonedInvocationCount, for asserting on leak-detection code paths.
-
simulateSignaling(
SignalingMessage message) → void - Simulates an incoming WebRTC signaling message.
-
simulateState(
RealtimeConnectionState newState) → void - Simulates a connection lifecycle state transition.
-
simulateTyping(
String room, String userId, bool isTyping) → void - Simulates an incoming typing indicator.
-
toString(
) → String -
A string representation of this object.
inherited
-
updatePresence(
PresenceStatus status, {String target = 'UpdatePresence'}) → Future< Either< RealtimeFailure, Unit> > -
Convenience API to update user presence status.
override
-
whenInvoke(
String methodName, dynamic result) → void -
Stubs the response returned by invoke or invokeAs for
methodName. -
whenInvokeThrows(
String methodName, RealtimeFailure failure) → void -
Stubs an error returned by invoke or invokeAs for
methodName.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited