Esempio n. 1
0
    public void OnPostBulkClick()
    {
        List <string> events = new List <string>();

        events.Add("{\"event\": \"test post 1\"}");
        events.Add("{\"event\": \"test post 2\"}");
        events.Add("{\"event\": \"test post 3\"}");

        api_.PutEvents("ibtest", events, ButtonEvent.ApiCallback);
    }
        /// <summary>
        /// Sends the data.
        /// </summary>
        /// <param name="stream">
        /// Stream.
        /// </param>
        /// <param name="data">
        /// Data.
        /// </param>
        /// <param name="dataSize">
        /// Data size.
        /// </param>
        /// <param name="method">
        /// Method.
        /// </param>
        /// <param name="callback">
        /// Callback.
        /// </param>
        protected IEnumerator SendData(string stream, string data, int dataSize = 1,
                                       HttpMethod method = HttpMethod.POST,
                                       Action <ironsource.Response> callback = null,
                                       bool isRetry = false, float timeout = 0)
        {
            if (isRetry)
            {
                yield return(new WaitForSeconds(timeout));
            }

            if (dataSize == 1)
            {
                api_.PutEvent(stream, data, method, callback);
            }
            else if (dataSize > 1)
            {
                api_.PutEvents(stream, data, callback);
            }
        }
        /// <summary>
        /// Flushs the data.
        /// </summary>
        /// <param name="stream">Stream.</param>
        /// <param name="authKey">Auth key.</param>
        /// <param name="data">Data.</param>
        private void FlushData(string stream, string authKey, List <string> data)
        {
            // data str
            // send data
            int attempt = 1;

            while (true)
            {
                Response response = api_.PutEvents(stream, data, authKey);
                PrintLog("data: " + data + "; response: " + response.status);
                if (response.status < 500 && response.status > 1)
                {
                    break;
                }

                int duration = (int)(GetDuration(attempt++) * 1000);
                Thread.Sleep(duration);

                PrintLog("Url: " + api_.GetEndpoint() + " Retry request: " + data);
            }
        }