Пример #1
0
        private void OnGsTcpClientError(object sender, GameServiceException exception)
        {
            if (_isDisposed)
            {
                return;
            }

            exception.LogException <TurnBasedHandler>(DebugLocation.TurnBased, "OnGsTcpClientError");

            if (PlayerHash != null)
            {
                try
                {
                    if (GameService.HandlerType == EventHandlerType.NativeContext)
                    {
                        TurnBasedEventHandlers.Reconnected?.Invoke(null, ReconnectStatus.Connecting);
                    }
                    else
                    {
                        GameService.SynchronizationContext?.Send(
                            delegate { TurnBasedEventHandlers.Reconnected?.Invoke(null, ReconnectStatus.Connecting); },
                            null);
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            _retryConnectCounter++;

            if (_retryConnectCounter >= TurnBasedConst.MaxRetryConnect)
            {
                DebugUtil.LogNormal <TurnBasedHandler>(DebugLocation.TurnBased, "OnGsTcpClientError",
                                                       "TurnBasedHandler Reached to MaxRetryConnect , so dispose TurnBased...");

                CoreEventHandlers.Dispose?.Invoke(this, new DisposeData
                {
                    Type = GSLiveType.TurnBased, IsGraceful = false
                });
                return;
            }

            DebugUtil.LogNormal <TurnBasedHandler>(DebugLocation.TurnBased, "OnGsTcpClientError",
                                                   "TurnBasedHandler reconnect Retry " + _retryConnectCounter + " , Wait to Connect...");

            _isPingRequested  = false;
            _retryPingCounter = 0;

            IsInitializing = false;

            Init();
        }
        private void OnGsTcpClientError(object sender, GameServiceException exception)
        {
            if (_isDisposed)
            {
                return;
            }

            _retryConnectCounter++;

            DebugUtil.LogError <CommandHandler>(DebugLocation.Command, "OnGsTcpClientError",
                                                "CommandHandler Reconnect Retry " + _retryConnectCounter + " , Wait to Connect...");

            _isPingRequested  = false;
            _retryPingCounter = 0;

            IsInitializing = false;

            Init();
        }