sendSimulateScenario method

Future<void> sendSimulateScenario({
  1. int? speakerUpdate,
  2. bool? nodeFailure,
  3. bool? migration,
  4. bool? serverLeave,
  5. bool? switchCandidate,
  6. bool? signalReconnect,
  7. bool? fullReconnect,
  8. int? subscriberBandwidth,
  9. bool? disconnectSignalOnResume,
  10. bool? disconnectSignalOnResumeNoMessages,
  11. bool? leaveRequestFullReconnect,
})

To be used for internal testing purposes only.

Client side scenarios, no server involvement:

  • signalReconnect drops the signal socket, the engine resumes.
  • fullReconnect drops the signal socket with a full reconnect pending.

Server side scenarios, forwarded as a SimulateScenario request. What the server does with them depends on the deployment; the open source server and Cloud differ for migration and nodeFailure.

  • disconnectSignalOnResume arms the server to close the signal socket right after answering the next resume, once its response messages have been sent. The socket is dropped immediately after arming so the resume starts, matching client-sdk-js.
  • disconnectSignalOnResumeNoMessages is the same, but the server closes the socket before sending anything, for the next three resumes.
  • leaveRequestFullReconnect makes the server send a Leave{RECONNECT}.

Implementation

Future<void> sendSimulateScenario({
  int? speakerUpdate,
  bool? nodeFailure,
  bool? migration,
  bool? serverLeave,
  bool? switchCandidate,
  bool? signalReconnect,
  bool? fullReconnect,
  int? subscriberBandwidth,
  bool? disconnectSignalOnResume,
  bool? disconnectSignalOnResumeNoMessages,
  bool? leaveRequestFullReconnect,
}) async {
  if (signalReconnect != null && signalReconnect) {
    await engine.signalClient.cleanUp();
    return;
  }
  if (fullReconnect != null && fullReconnect) {
    engine.fullReconnectOnNext = true;
    await engine.signalClient.cleanUp();
    return;
  }
  engine.signalClient.sendSimulateScenario(
    speakerUpdate: speakerUpdate,
    nodeFailure: nodeFailure,
    migration: migration,
    serverLeave: serverLeave,
    switchCandidate: switchCandidate,
    subscriberBandwidth: subscriberBandwidth,
    disconnectSignalOnResume: disconnectSignalOnResume,
    disconnectSignalOnResumeNoMessages: disconnectSignalOnResumeNoMessages,
    leaveRequestFullReconnect: leaveRequestFullReconnect,
  );
  // The server only acts on the next resume, so start one now. Mirrors the
  // post action in client-sdk-js.
  if ((disconnectSignalOnResume ?? false) || (disconnectSignalOnResumeNoMessages ?? false)) {
    await engine.signalClient.cleanUp();
  }
}