Пример #1
0
        public async Task TransferPushSocket()
        {
            //return;
            if (!_instaApi.IsUserAuthenticated || _runningTokenSource.IsCancellationRequested)
            {
                return;
            }
            if (DontTransferSocket)
            {
                return;
            }
            Log($"[{_instaApi.GetLoggedUser().UserName}] " + "Transferring sockets");
            await SendPing().ConfigureAwait(false);

            await Task.Delay(TimeSpan.FromSeconds(3.5));  // grace period

            Shutdown();
            await Socket.CancelIOAsync();


            Socket.TransferOwnership(
                SOCKET_ID
                ,
                null,
                TimeSpan.FromSeconds(KEEP_ALIVE - 60)

                );
            //Socket.Dispose();
        }
Пример #2
0
        /// <summary>
        /// Transfer socket as well as necessary context for background push notification client.
        /// Transfer only happens if user is logged in.
        /// </summary>
        public async Task TransferPushSocket()
        {
            if (!_instaApi.IsUserAuthenticated || _loopGroup == null)
            {
                return;
            }

            // Hand over MQTT socket to socket broker
            Debug.WriteLine($"{nameof(PushClient)}: Transferring sockets.");
            await SendPing().ConfigureAwait(false);
            await Shutdown().ConfigureAwait(false);

            await Socket.CancelIOAsync();

            Socket.TransferOwnership(
                SOCKET_ID,
                null,
                TimeSpan.FromSeconds(KEEP_ALIVE - 60));
        }