Exemplo n.º 1
0
        private async void InitializeSDK()
        {
            if (String.IsNullOrEmpty(SecretKey))
            {
                Messages.ShowMessage(Messages.SecretKeyRquired);
                return;
            }

            IsSDKInitializing = true;

            var countries = new List <Country>();
            var protocols = new List <Protocol>();

            await Task.Factory.StartNew(() =>
            {
                //Can be initialized using this
                atomManagerInstance = AtomManager.Initialize(SecretKey);
                //Or this
                //var atomConfig = new AtomConfiguration(SecretKey);
                //atomManagerInstance = AtomManager.Initialize(atomConfig);

                atomManagerInstance.Connected                += AtomManagerInstance_Connected;
                atomManagerInstance.DialError                += AtomManagerInstance_DialError;
                atomManagerInstance.Disconnected             += AtomManagerInstance_Disconnected;
                atomManagerInstance.StateChanged             += AtomManagerInstance_StateChanged;
                atomManagerInstance.Redialing                += AtomManagerInstance_Redialing;
                atomManagerInstance.OnUnableToAccessInternet += AtomManagerInstance_OnUnableToAccessInternet;
                atomManagerInstance.SDKAlreadyInitialized    += AtomManagerInstance_SDKAlreadyInitialized;

                atomManagerInstance.AutoRedialOnConnectionDrop = true;

                //To get countries
                try
                {
                    countries = atomManagerInstance.GetCountries();
                }
                catch { }

                //To get protocols
                try
                {
                    protocols = atomManagerInstance.GetProtocols();
                }
                catch { }

                //AtomHelper lets you use the functionality of above created instance in all usercontrols and pages
                AtomHelper.SetAtomManagerInstance(atomManagerInstance);
            });

            ConnectionWithDedicatedIP.Initialize(protocols, countries);
            ConnectionWithParams.Initialize(protocols, countries);
            IsSDKInitializing    = false;
            ISSDKInitialized     = true;
            IsConnDisconnAllowed = true;
        }
Exemplo n.º 2
0
        private async void InitializeSDK()
        {
            if (String.IsNullOrEmpty(SecretKey))
            {
                Messages.ShowMessage(Messages.SecretKeyRquired);
                return;
            }

            IsSDKInitializing = true;

            var countries = new List <Country>();
            var protocols = new List <Protocol>();

            await Task.Factory.StartNew(() =>
            {
                //Can be initialized using this
                atomManagerInstance = AtomManager.Initialize(SecretKey);
                //Or this
                //var atomConfig = new AtomConfiguration(SecretKey);
                //atomManagerInstance = AtomManager.Initialize(atomConfig);

                atomManagerInstance.Connected                += AtomManagerInstance_Connected;
                atomManagerInstance.DialError                += AtomManagerInstance_DialError;
                atomManagerInstance.Disconnected             += AtomManagerInstance_Disconnected;
                atomManagerInstance.StateChanged             += AtomManagerInstance_StateChanged;
                atomManagerInstance.Redialing                += AtomManagerInstance_Redialing;
                atomManagerInstance.OnUnableToAccessInternet += AtomManagerInstance_OnUnableToAccessInternet;
                atomManagerInstance.SDKAlreadyInitialized    += AtomManagerInstance_SDKAlreadyInitialized;
                atomManagerInstance.ConnectedLocation        += AtomManagerInstance_ConnectedLocation;
                atomManagerInstance.AtomInitialized          += AtomManagerInstance_AtomInitialized;
                atomManagerInstance.AtomDependenciesMissing  += AtomManagerInstance_AtomDependenciesMissing;

                // Add sensitive application that needs to be close if network connections drops automatically.
                atomManagerInstance.SensitiveApplications = new List <SensitiveApplication>()
                {
                    new SensitiveApplication()
                    {
                        CompleteExePath = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
                    }
                };

                atomManagerInstance.AutoRedialOnConnectionDrop = true;

                //To get countries
                try
                {
                    countries = atomManagerInstance.GetCountries();
                }
                catch { }

                //To get protocols
                try
                {
                    protocols = atomManagerInstance.GetProtocols();
                }
                catch { }

                //AtomHelper lets you use the functionality of above created instance in all usercontrols and pages
                AtomHelper.SetAtomManagerInstance(atomManagerInstance);
            });

            ConnectionWithDedicatedIP.Initialize(protocols, countries);
            ConnectionWithParams.Initialize(protocols, countries);
            IsSDKInitializing    = false;
            ISSDKInitialized     = true;
            IsConnDisconnAllowed = true;
        }