listen method

void listen(
  1. dynamic channel,
  2. dynamic cache,
  3. bool disconnected
)

The listen method is called to listen to the websocket channel. It will send a request to the websocket channel every 30 seconds for the failed keys.

The channel is the websocket channel. The cache is the memory cache. The disconnected is a boolean to check if the websocket is disconnected.

Implementation

void listen(var channel, var cache, bool disconnected) {
  if (disconnected) return;
  if (channel == null) return;

  Timer.periodic(const Duration(seconds: 30), (timer) {
    if (failedKeys.isEmpty) return;
    for (var entry in failedKeys) {
      channel!.sink._addToSink(entry.websocketData);
    }
    failedKeys = [];
  });
}