How to use the leancloud-realtime.Event.RECONNECT function in leancloud-realtime

To help you get started, we’ve selected a few leancloud-realtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leancloud / leanmessage-demo / src / app / conversation / conversation.controller.js View on Github external
client.on(Event.ONLINE, () => {
    $scope.networkError = '网络已恢复';
    $scope.$digest();
  });
  client.on(Event.SCHEDULE, (attempt, time) => {
    $scope.networkError = `${time / 1000}s 后进行第 ${attempt + 1} 次重连`;
    $scope.networkShowRetry = true;
    $scope.$digest();
  });
  client.on(Event.RETRY, attempt => {
    $scope.networkError = `正在进行第 ${attempt + 1} 次重连`;
    $scope.networkErrorIcon = 'sync';
    $scope.networkShowRetry = false;
    $scope.$digest();
  });
  client.on(Event.RECONNECT, () => {
    $scope.networkError = null;
    if ($scope.joinedTransConv) {
      $scope.joinedTransConv.join();
    }
    $scope.$digest();
  });
  client.on(Event.RECONNECT_ERROR, () => {
    $scope.networkError = '重连失败,请刷新页面重试';
    $scope.networkErrorIcon = 'error_outline';
    $scope.$digest();
  });

  $scope.$on("$destroy", () => {
    client.off(Event.MESSAGE, messageHandler);
    client.off(Event.INVITED, invitedHandler);
    [
github leancloud / leanmessage-demo / src / app / conversation / conversation.controller.js View on Github external
$scope.$on("$destroy", () => {
    client.off(Event.MESSAGE, messageHandler);
    client.off(Event.INVITED, invitedHandler);
    [
      Event.UNREAD_MESSAGES_COUNT_UPDATE,
      Event.DISCONNECT,
      Event.OFFLINE,
      Event.ONLINE,
      Event.SCHEDULE,
      Event.RETRY,
      Event.RECONNECT,
      Event.RECONNECT_ERROR
    ].forEach(event => client.off(event));
  });