// note: we may have multiple connections with a host, so // possibly multiple entries per host (each with a different // id), so we do not use the host as the hashtable key static public void Add(string host, byte[] id) { lock (locker) { string uid = BitConverter.ToString(id); ClientSessionInfo si = (ClientSessionInfo)cache[uid]; if (si == null) { cache.Add(uid, new ClientSessionInfo(host, id)); } else if (si.HostName == host) { // we already have this and it's still valid // on the server, so we'll keep it a little longer si.KeepAlive(); } else { // it's very unlikely but the same session id // could be used by more than one host. In this // case we replace the older one with the new one si.Dispose(); cache.Remove(uid); cache.Add(uid, new ClientSessionInfo(host, id)); } } }
static public bool SetContextFromCache(Context context) { lock (locker) { ClientSessionInfo csi = FromContext(context, true); if (csi == null) { return(false); } csi.SetContext(context); csi.KeepAlive(); return(true); } }
public static bool SetContextInCache(Context context) { lock (ClientSessionCache.locker) { ClientSessionInfo clientSessionInfo = ClientSessionCache.FromContext(context, false); if (clientSessionInfo == null) { return(false); } clientSessionInfo.GetContext(context); clientSessionInfo.KeepAlive(); return(true); } }
static public bool SetContextInCache(Context context) { lock (locker) { // Don't check the validity because the masterKey of the ClientSessionInfo // can still be null when this is called the first time ClientSessionInfo csi = FromContext(context, false); if (csi == null) { return(false); } csi.GetContext(context); csi.KeepAlive(); return(true); } }
public static bool SetContextInCache(Context context) { lock (locker) { ClientSessionInfo clientSessionInfo = FromContext(context, checkValidity: false); if (clientSessionInfo == null) { return(false); } clientSessionInfo.GetContext(context); clientSessionInfo.KeepAlive(); return(true); IL_0035: bool result; return(result); } }
public static byte[] FromHost(string host) { object obj = ClientSessionCache.locker; byte[] result; lock (obj) { foreach (object obj2 in ClientSessionCache.cache.Values) { ClientSessionInfo clientSessionInfo = (ClientSessionInfo)obj2; if (clientSessionInfo.HostName == host && clientSessionInfo.Valid) { clientSessionInfo.KeepAlive(); return(clientSessionInfo.Id); } } result = null; } return(result); }
public static bool SetContextInCache(Context context) { object obj = ClientSessionCache.locker; bool result; lock (obj) { ClientSessionInfo clientSessionInfo = ClientSessionCache.FromContext(context, false); if (clientSessionInfo == null) { result = false; } else { clientSessionInfo.GetContext(context); clientSessionInfo.KeepAlive(); result = true; } } return(result); }
public static void Add(string host, byte[] id) { lock (ClientSessionCache.locker) { string str = BitConverter.ToString(id); ClientSessionInfo clientSessionInfo = (ClientSessionInfo)ClientSessionCache.cache[(object)str]; if (clientSessionInfo == null) { ClientSessionCache.cache.Add((object)str, (object)new ClientSessionInfo(host, id)); } else if (clientSessionInfo.HostName == host) { clientSessionInfo.KeepAlive(); } else { clientSessionInfo.Dispose(); ClientSessionCache.cache.Remove((object)str); ClientSessionCache.cache.Add((object)str, (object)new ClientSessionInfo(host, id)); } } }
public static void Add(string host, byte[] id) { lock (locker) { string key = BitConverter.ToString(id); ClientSessionInfo clientSessionInfo = (ClientSessionInfo)cache[key]; if (clientSessionInfo == null) { cache.Add(key, new ClientSessionInfo(host, id)); } else if (clientSessionInfo.HostName == host) { clientSessionInfo.KeepAlive(); } else { clientSessionInfo.Dispose(); cache.Remove(key); cache.Add(key, new ClientSessionInfo(host, id)); } } }