public void Reset()
 {
     lock (@lock)
     {
         CyclicExchangeStop();
         LicenseClient             = null;
         InterfaceAppManagerAtTime = null;
     }
 }
 public ExchangeReport Exchange(LicenseClientConfig licenseClientConfig, int?skipIfNotNeededForSessionKeepAliveSafetyMarginMilli)
 {
     lock (@lock)
     {
         PropertyGenTimespanInt64 <HttpExchangeReport <AuthRequest, AuthResponse> > authExchange = null;
         PropertyGenTimespanInt64 <HttpExchangeReport <FromClientToServerMessage, FromServerToClientMessage> > propertyGenTimespanInt = null;
         LicenseClientConfig obj = licenseClientConfig ?? LicenseClientConfig;
         licenseClientConfig = obj;
         LicenseClientConfig = obj;
         LicenseClient licenseClient = LicenseClient ?? (LicenseClient = new LicenseClient());
         if (licenseClientConfig != null)
         {
             licenseClient.ServerAddress = licenseClientConfig?.ApiVersionAddress;
             licenseClient.Request       = licenseClientConfig?.Request;
         }
         if (SessionContinue)
         {
             IRateLimitStateInt exchangePayloadRateLimit = ExchangePayloadRateLimit;
             long timeMilli = GetTimeMilli();
             var  obj2      = licenseClient?.ExchangeAuthLast?.Value?.Response?.RequestTimeDistanceMaxMilli -
                              skipIfNotNeededForSessionKeepAliveSafetyMarginMilli;
             if (!exchangePayloadRateLimit.AttemptPass(timeMilli, Math.Max(1000, obj2 ?? 0)))
             {
                 return(null);
             }
             object obj3;
             if (licenseClient == null)
             {
                 obj3 = null;
             }
             else
             {
                 PropertyGenTimespanInt64 <HttpExchangeReport <AuthRequest, AuthResponse> > exchangeAuthLast2 = licenseClient.ExchangeAuthLast;
                 obj3 = exchangeAuthLast2?.Value?.Response?.SessionId;
             }
             string sessionId = (string)obj3;
             FromClientToServerMessage request = new FromClientToServerMessage
             {
                 SessionId = sessionId,
                 Interface = InterfaceAppManager?.ToServer(),
                 Time      = GetTimeMilli()
             };
             propertyGenTimespanInt = licenseClient?.ExchangePayload(request);
             FromServerToClientMessage fromServerToClientMessage = propertyGenTimespanInt?.Value?.Response;
             if (fromServerToClientMessage != null)
             {
                 InterfaceAppManager?.FromServer(fromServerToClientMessage.Interface);
             }
         }
         else if (licenseClient?.AuthCompleted ?? false)
         {
             long?obj4;
             if (licenseClient == null)
             {
                 obj4 = null;
             }
             else
             {
                 PropertyGenTimespanInt64 <HttpExchangeReport <AuthRequest, AuthResponse> > exchangeAuthLast3 = licenseClient.ExchangeAuthLast;
                 obj4 = ((exchangeAuthLast3 != null) ? new long?(exchangeAuthLast3.End) : null);
             }
             long?num = obj4;
             PropertyGenTimespanInt64 <InterfaceAppManager> interfaceAppManagerAtTime = InterfaceAppManagerAtTime;
             if (!(num < ((interfaceAppManagerAtTime != null) ? new long?(interfaceAppManagerAtTime.Begin) : null)))
             {
                 InterfaceAppManagerAtTime = new PropertyGenTimespanInt64 <InterfaceAppManager>(new InterfaceAppManager(InterfaceAppDomainSetupType, InterfaceAppDomainSetupTypeLoadFromMainModule), GetTimeMilli());
             }
         }
         else
         {
             int    exchangeAuthTimeDistanceMinMilli = ExchangeAuthTimeDistanceMinMilli;
             object authResponse;
             if (licenseClient == null)
             {
                 authResponse = null;
             }
             else
             {
                 PropertyGenTimespanInt64 <HttpExchangeReport <AuthRequest, AuthResponse> > exchangeAuthLast4 = licenseClient.ExchangeAuthLast;
                 authResponse = ((exchangeAuthLast4 == null) ? null : exchangeAuthLast4.Value?.Response);
             }
             int num2 = Math.Max(exchangeAuthTimeDistanceMinMilli, AuthTimeDistanceRecommended((AuthResponse)authResponse) ?? 0);
             if (ExchangeAuthRateLimit.AttemptPass(GetTimeMilli(), num2))
             {
                 authExchange = licenseClient?.ExchangeAuth();
             }
         }
         return(new ExchangeReport
         {
             AuthExchange = authExchange,
             PayloadExchange = propertyGenTimespanInt
         });
     }
 }
Exemple #3
0
 public static PropertyGenTimespanInt64 <HttpExchangeReport <AuthRequest, AuthResponse> > ExchangeAuthLastStillValid(this LicenseClient client)
 {
     return((client == null || !client.AuthCompleted) ? null : client?.ExchangeAuthLast);
 }