fetch method

  1. @override
Future<bool> fetch(
  1. String channel,
  2. int timestamp, {
  3. int timeoutSeconds = 5,
})
override

Implementation

@override
Future<bool> fetch(String channel, int timestamp,
    {int timeoutSeconds = 5}) async {
  Completer<bool> completer = Completer();
  Push push = phoenixChannel.push("fetch", {
    "channel": channel,
    "timestamp": timestamp,
  });
  push.onReply("ok", (PushResponse pushResponse) {
    completer.complete(true);
  });
  push.onReply("error", (PushResponse pushResponse) {
    completer.complete(false);
  });
  Future.delayed(Duration(seconds: timeoutSeconds), () {
    if (!completer.isCompleted) {
      completer.complete(false);
    }
  });
  return completer.future;
}