/// <summary>
        /// Creates the client async.
        /// </summary>
        /// <returns>The client async.</returns>
        /// <param name="user">User.</param>
        /// <param name="tag">Tag.</param>
        /// <param name="deviceId">Device identifier.</param>
        /// <param name="secure">If set to <c>true</c> secure.</param>
        public Task <AVIMClient> CreateClientAsync(AVUser user     = null,
                                                   string tag      = null,
                                                   string deviceId = null,
                                                   bool secure     = true,
                                                   CancellationToken cancellationToken = default(CancellationToken))
        {
            AVIMClient client = null;

            AVRealtime.PrintLog("begin OpenAsync.");
            return(OpenAsync(secure, Subprotocol, true, cancellationToken).OnSuccess(openTask =>
            {
                AVRealtime.PrintLog("OpenAsync OnSuccess. begin send open sesstion cmd.");
                var userTask = Task.FromResult(user);
                if (user == null)
                {
                    userTask = AVUser.GetCurrentUserAsync();
                }

                return userTask;
            }).Unwrap().OnSuccess(u =>
            {
                var theUser = u.Result;
                return AVCloud.RequestRealtimeSignatureAsync(theUser);
            }).Unwrap().OnSuccess(signTask =>
            {
                var signResult = signTask.Result;
                var clientId = signResult.ClientId;
                var nonce = signResult.Nonce;
                var singnature = signResult.Signature;
                var ts = signResult.Timestamp;

                client = PreLogIn(clientId, tag, deviceId);
                ToggleNotification(true);
                return this.OpenSessionAsync(clientId, tag, deviceId, nonce, ts, singnature, secure);
            }).Unwrap().OnSuccess(s =>
            {
                ToggleHeartBeating(true);
                AfterLogIn(client);
                return client;
            }));
        }
        /// <summary>
        /// Creates the client async.
        /// </summary>
        /// <returns>The client async.</returns>
        /// <param name="user">User.</param>
        /// <param name="tag">Tag.</param>
        /// <param name="deviceId">Device identifier.</param>
        /// <param name="secure">If set to <c>true</c> secure.</param>
        public Task <AVIMClient> CreateClientAsync(AVUser user     = null,
                                                   string tag      = null,
                                                   string deviceId = null,
                                                   bool secure     = true)
        {
            var userTask = Task.FromResult(user);

            if (user == null)
            {
                userTask = AVUser.GetCurrentUserAsync();
            }

            AVIMClient client = null;

            return(userTask.OnSuccess(u =>
            {
                var theUser = u.Result;
                return AVCloud.RequestRealtimeSignatureAsync(theUser);
            }).Unwrap().OnSuccess(signTask =>
            {
                var signResult = signTask.Result;
                var clientId = signResult.ClientId;
                var nonce = signResult.Nonce;
                var singnature = signResult.Signature;
                var ts = signResult.Timestamp;

                client = PreLogIn(clientId, tag, deviceId);
                ToggleNotification(true);
                return this.OpenSessionAsync(clientId, tag, deviceId, nonce, ts, singnature, secure);
            }).Unwrap().OnSuccess(s =>
            {
                ToggleHeartBeating(_heartBeatingToggle);

                return client;
            }));
        }