예제 #1
0
        private static void ExpireSession(UserCredential currentCred)
        {
            ConnectionSession currentSession =
                currentCred.Sessions.Find(sess =>
                                          sess.DisconnectedTime == 0);

            if (currentSession != null &&
                currentSession.DisconnectedTime == 0)
            {
                currentSession.DisconnectedTime = DateTime.Now.Ticks;
            }
        }
예제 #2
0
        private void PingClients()
        {
            var hubContext =
                GlobalHost
                .ConnectionManager
                .GetHubContext <GameNotificationHub>();

            foreach (var item in _connections.Values)
            {
                TimeSpan span =
                    new TimeSpan(item.GetSessionLengthInTicks());
                ConnectionSession session =
                    item.Sessions[item.Sessions.Count - 1];
                hubContext.Clients.All
                .tick(session.ConnectionId, item.UserId, span.ToString());
            }
        }
예제 #3
0
        internal void Disconnect(string connectionId)
        {
            ConnectionSession session = null;

            if (_connections.Values.Count > 0)
            {
                foreach (var currentCredi in _connections.Values)
                {
                    session = currentCredi.Sessions.Find(ss =>
                                                         ss.ConnectionId == connectionId);
                    if (session != null)
                    {
                        session.DisconnectedTime = DateTime.Now.Ticks;
                        break;
                    }
                }
            }
        }