/// <summary> /// Clears references to used instances. /// </summary> private void ClearReferences() { if (this.m_gameObject != null) { GameObject.Destroy(this.m_gameObject); this.m_gameObject = null; this.m_helper = null; } if (this.m_localStorage != null) { this.m_localStorage.Destroy(); this.m_localStorage = null; } if (this.m_network != null) { this.m_network.Destroy(); this.m_network = null; } if (this.m_pendingMessages != null) { this.m_pendingMessages.Destroy(); this.m_pendingMessages = null; } if (this.m_sendingMessages != null) { this.m_sendingMessages.Destroy(); this.m_sendingMessages = null; } if (this.m_ids != null) { this.m_ids.Destroy(); this.m_ids = null; } }
/// <summary> /// Initializes the instance. This method takes care of all initialization. /// </summary> /// <param name="anApiKey">API key</param> /// <param name="aSecretKey">API secret</param> /// <param name="aPayable">Initial payable value.</param> private void Initialize(string anApiKey, string aSecretKey, bool aPayable) { // exit if already initialized if (this.Initialized) { this.AddLog("[Init] WARNING: already initialized"); return; } // create a game object and attach the internal component to it this.m_gameObject = new GameObject("__IQU_SDK__"); this.m_helper = this.m_gameObject.AddComponent<IQUHelper>(); // create local storage this.m_localStorage = new IQULocalStorage(); // create network this.m_network = new IQUNetwork(anApiKey, aSecretKey); // create device this.m_device = new IQUDevice(); // create message queues this.m_pendingMessages = new IQUMessageQueue(); this.m_sendingMessages = new IQUMessageQueue(); // update properties this.Payable = aPayable; // retrieve or create an unique ID this.ObtainSdkId(); // wait for device this.m_state = State.WaitForDevice; // start initializing the the device this.m_device.Initialize(); // update properties this.SetInitialized(true); // debug this.AddLog("[Init] %IQU %SDK is initialized"); }
/// <summary> /// Creates the instance and initializes all private variables. /// </summary> private IQUSDK() { this.m_checkServerInterval = IQUSDK.DefaultCheckServerInterval; this.m_checkServerTime = -IQUSDK.DefaultCheckServerInterval; this.m_device = null; this.m_analyticsEnabled = true; this.m_gameObject = null; this.m_heartbeatTime = -IQUSDK.HeartbeatInterval; this.m_helper = null; this.m_ids = new IQUIds(); this.m_initialized = false; this.m_localStorage = null; this.m_log = ""; #if DEBUG || UNITY_EDITOR this.m_logEnabled = true; #else this.m_logEnabled = false; #endif this.m_network = null; this.m_paused = false; this.m_payable = true; this.m_pendingMessages = null; this.m_sendingMessages = null; this.m_serverAvailable = true; this.m_state = State.None; this.m_testMode = IQUTestMode.None; }