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; } }
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()); } }
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; } } } }