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