static public bool SetContextFromCache(Context context) { lock (locker) { ServerSessionInfo csi = FromContext(context, true); if (csi == null) { return(false); } csi.SetContext(context); csi.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 ServerSessionInfo csi = FromContext(context, false); if (csi == null) { return(false); } csi.GetContext(context); csi.KeepAlive(); return(true); } }
static public void Add(byte[] id) { lock (locker) { string uid = BitConverter.ToString(id); ServerSessionInfo si = (ServerSessionInfo)cache[uid]; if (si == null) { cache.Add(uid, new ServerSessionInfo(id)); } else { // we already have this and it's still valid // on the server, so we'll keep it a little longer si.KeepAlive(); } } }