Exemplo n.º 1
0
        public async Task <bool> ReconnectAsync()
        {
            if (_client == null) // we cannot reconnect before we have done a first connection!
            {
                return(false);
            }

            try
            {
                _reconnecting = true;

                if (IsConnected)
                {
                    await _client.ReconnectOrFail();
                }
                else
                {
                    await _client.StartOrFail();
                    await OnReconnect(new ReconnectionInfo(ReconnectionType.ByServer));
                }

                _reconnecting = false;

                return(true);
            }
            catch
            {
                return(await ReconnectAsync()); // if reconnect or start fails we just wanna re-try
            }
        }