setReconnect method Null safety
inherited
Sets reconnection if autoReconnect is enabled.
Implementation
setReconnect() {
signaling?.on('migrate', this, (ev, context) async {
signaling?.isMigrating = true;
await replaceConnection();
signaling?.isMigrating = false;
});
if (autoReconnect) {
signaling?.on(SignalingEvents.connectionError, this, (event, context) {
if ((firstReconnection == null || alreadyDisconnected == false)) {
firstReconnection = false;
reconnect();
}
});
webRTCPeer.on(webRTCEvents['connectionStateChange'], this,
(event, context) {
var state = event.eventData;
if ((state == 'failed' ||
(state == 'disconnected' && alreadyDisconnected!)) &&
firstReconnection!) {
firstReconnection = false;
reconnect();
} else if (state == 'disconnected') {
alreadyDisconnected = true;
Timer(const Duration(milliseconds: 1500), () => reconnect());
} else {
alreadyDisconnected = false;
}
});
}
}