public static int NewSession(SessionModel model) { // Ephemeral in memory single webserver storage... // In a legit app this would go into elasticache or redis or some equiv // caching layer, or a NoSql store if you wanted to persist it... int newSessionID = Interlocked.Increment(ref SessionID); SessionCache.Add(newSessionID, model); return(newSessionID); }
private async Task <MobileConnectStatus> CacheIfRequired(MobileConnectStatus status) { if (!_cacheWithSessionId || status.ResponseType != MobileConnectResponseType.StartAuthentication || status.DiscoveryResponse == null) { return(status); } var sessionId = Security.GenerateSecureNonce(); await _sessionCahce.Add(sessionId, status.DiscoveryResponse).ConfigureAwait(false); status.SDKSession = sessionId; return(status); }
private async void SetSessionCache(MobileConnectStatus status, DiscoveryResponse discoveryResponse, string nonce) { await SessionCache.Add(status.State, new SessionData(discoveryResponse, nonce)); }
private async void SetSessionCache(MobileConnectStatus status, string msisdn, string mcc, string mnc, string sourceIp) { await SessionCache.Add(status.State, new SessionData(DiscoveryCache.Get(StringUtils.FormatKey(msisdn, mcc, mnc, sourceIp)), status.Nonce)); }