newState and oldState on ConnectionStateUpdatedEvent
This commit is contained in:
@@ -592,7 +592,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
|
|||||||
events.emit(event);
|
events.emit(event);
|
||||||
})
|
})
|
||||||
..on<SignalConnectionStateUpdatedEvent>((event) async {
|
..on<SignalConnectionStateUpdatedEvent>((event) async {
|
||||||
if (event.connectionState == ConnectionState.disconnected) {
|
if (event.newState == ConnectionState.disconnected) {
|
||||||
await _onDisconnected(DisconnectReason.signal);
|
await _onDisconnected(DisconnectReason.signal);
|
||||||
}
|
}
|
||||||
// Relay to Room
|
// Relay to Room
|
||||||
|
|||||||
@@ -152,10 +152,12 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {
|
|||||||
bool didReconnect = _connectionState == ConnectionState.reconnecting &&
|
bool didReconnect = _connectionState == ConnectionState.reconnecting &&
|
||||||
newValue == ConnectionState.connected;
|
newValue == ConnectionState.connected;
|
||||||
|
|
||||||
|
final oldState = _connectionState;
|
||||||
_connectionState = newValue;
|
_connectionState = newValue;
|
||||||
|
|
||||||
events.emit(SignalConnectionStateUpdatedEvent(
|
events.emit(SignalConnectionStateUpdatedEvent(
|
||||||
connectionState: _connectionState,
|
newState: _connectionState,
|
||||||
|
oldState: oldState,
|
||||||
didReconnect: didReconnect,
|
didReconnect: didReconnect,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,23 +89,41 @@ class SignalJoinResponseEvent with SignalEvent, EngineEvent, InternalEvent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Base class for a ConnectionStateUpdated event
|
||||||
@internal
|
@internal
|
||||||
class SignalConnectionStateUpdatedEvent
|
abstract class ConnectionStateUpdatedEvent with EngineEvent, InternalEvent {
|
||||||
with SignalEvent, EngineEvent, InternalEvent {
|
final ConnectionState newState;
|
||||||
final ConnectionState connectionState;
|
final ConnectionState oldState;
|
||||||
final bool didReconnect;
|
final bool didReconnect;
|
||||||
final DisconnectReason? disconnectReason;
|
final DisconnectReason? disconnectReason;
|
||||||
const SignalConnectionStateUpdatedEvent({
|
const ConnectionStateUpdatedEvent({
|
||||||
required this.connectionState,
|
required this.newState,
|
||||||
|
required this.oldState,
|
||||||
required this.didReconnect,
|
required this.didReconnect,
|
||||||
this.disconnectReason,
|
this.disconnectReason,
|
||||||
});
|
});
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType(state: ${connectionState.name}, '
|
String toString() => '$runtimeType(newState: ${newState.name}, '
|
||||||
'didReconnect: ${didReconnect}, '
|
'didReconnect: ${didReconnect}, '
|
||||||
'disconnectReason: ${disconnectReason})';
|
'disconnectReason: ${disconnectReason})';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@internal
|
||||||
|
class SignalConnectionStateUpdatedEvent extends ConnectionStateUpdatedEvent
|
||||||
|
with SignalEvent {
|
||||||
|
const SignalConnectionStateUpdatedEvent({
|
||||||
|
required ConnectionState newState,
|
||||||
|
required ConnectionState oldState,
|
||||||
|
required bool didReconnect,
|
||||||
|
DisconnectReason? disconnectReason,
|
||||||
|
}) : super(
|
||||||
|
newState: newState,
|
||||||
|
oldState: oldState,
|
||||||
|
didReconnect: didReconnect,
|
||||||
|
disconnectReason: disconnectReason,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@internal
|
@internal
|
||||||
class SignalOfferEvent with SignalEvent, InternalEvent {
|
class SignalOfferEvent with SignalEvent, InternalEvent {
|
||||||
final rtc.RTCSessionDescription sd;
|
final rtc.RTCSessionDescription sd;
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ void main() {
|
|||||||
client.events.streamCtrl.stream,
|
client.events.streamCtrl.stream,
|
||||||
emitsInOrder(<Matcher>[
|
emitsInOrder(<Matcher>[
|
||||||
predicate<SignalConnectionStateUpdatedEvent>(
|
predicate<SignalConnectionStateUpdatedEvent>(
|
||||||
(event) => event.connectionState == ConnectionState.connecting),
|
(event) => event.newState == ConnectionState.connecting),
|
||||||
predicate<SignalConnectionStateUpdatedEvent>(
|
predicate<SignalConnectionStateUpdatedEvent>(
|
||||||
(event) => event.connectionState == ConnectionState.connected),
|
(event) => event.newState == ConnectionState.connected),
|
||||||
]));
|
]));
|
||||||
await client.connect(exampleUri, token);
|
await client.connect(exampleUri, token);
|
||||||
});
|
});
|
||||||
@@ -36,9 +36,9 @@ void main() {
|
|||||||
client.events.streamCtrl.stream,
|
client.events.streamCtrl.stream,
|
||||||
emitsInOrder(<Matcher>[
|
emitsInOrder(<Matcher>[
|
||||||
predicate<SignalConnectionStateUpdatedEvent>((event) =>
|
predicate<SignalConnectionStateUpdatedEvent>((event) =>
|
||||||
event.connectionState == ConnectionState.reconnecting),
|
event.newState == ConnectionState.reconnecting),
|
||||||
predicate<SignalConnectionStateUpdatedEvent>((event) =>
|
predicate<SignalConnectionStateUpdatedEvent>((event) =>
|
||||||
event.connectionState == ConnectionState.connected &&
|
event.newState == ConnectionState.connected &&
|
||||||
event.didReconnect == true),
|
event.didReconnect == true),
|
||||||
]));
|
]));
|
||||||
await client.connect(exampleUri, token, reconnect: true);
|
await client.connect(exampleUri, token, reconnect: true);
|
||||||
|
|||||||
Reference in New Issue
Block a user