예제 #1
0
        protected Task WaitForState(AblyRealtime realtime, ConnectionState awaitedState = ConnectionState.Connected, TimeSpan?waitSpan = null)
        {
            var connectionAwaiter = new ConnectionAwaiter(realtime.Connection, awaitedState);

            if (waitSpan.HasValue)
            {
                return(connectionAwaiter.Wait(waitSpan.Value));
            }
            return(connectionAwaiter.Wait());
        }
예제 #2
0
        internal static Task <TimeSpan> WaitForState(this AblyRealtime realtime, ConnectionState awaitedState, TimeSpan?waitSpan = null)
        {
            if (realtime.Connection.State == awaitedState)
            {
                return(Task.FromResult(TimeSpan.Zero));
            }

            var connectionAwaiter = new ConnectionAwaiter(realtime.Connection, awaitedState);

            if (waitSpan.HasValue)
            {
                return(connectionAwaiter.Wait(waitSpan.Value));
            }

            return(connectionAwaiter.Wait());
        }