void InvokeInitializationHandlerAndDeleteReference(bool success) { isInitializing = false; if (initializationEventHandler != null) { initializationEventHandler(success); } initializationEventHandler = null; }
/// <inheritdoc /> public void Initialize(InitializeTranslatorEventHandler eventHandler, string clientID, string clientSecret) { if (eventHandler == null) { Debug.LogError("There's no valid event handler set to initialize! Aborting process"); return; } if (clientID == null || clientSecret == null) { Debug.LogError("There's no valid clientID & Secret set to initialize! Aborting process"); eventHandler(false); return; } if (initializationEventHandler != null) { Debug.LogError("There's already an ongoing initialization process. Aborting.."); eventHandler(false); return; } timeForTokenToExpire = new DateTime(1, 1, 1); initializationEventHandler = eventHandler; isInitialized = false; isInitializing = true; didExpire = false; this.clientID = clientID.RemoveWhitespace(); this.clientSecret = clientSecret.RemoveWhitespace(); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(AcceptAllCertifications); WebRequest request = System.Net.WebRequest.Create(AuthenticationURL); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.BeginGetRequestStream(new AsyncCallback(PrepareAuthenticationRequest), request); }