/// <summary>
        /// Track the specified stream and data.
        /// </summary>
        /// <param name="stream">
        /// Name of stream.
        /// </param>
        /// <param name="data">
        /// Data.
        /// </param>
        public void Track(string stream, string data,
                          Action <string, string, Dictionary <string, ironsource.BulkData> > errorCallback = null)
        {
            if (!bulkDataMap_.ContainsKey(stream))
            {
                bulkDataMap_[stream] = new BulkData();
            }

            if (bulkDataMap_[stream].GetSize() >= backlogSize_)
            {
                string errorStr = "Message store for stream: '" + stream + "' has reached its maximum size!";
                PrintLog(errorStr);
                if (errorCallback != null)
                {
                    errorCallback(errorStr, stream, bulkDataMap_);
                }
                return;
            }

            BulkData bulkData = bulkDataMap_[stream];

            bulkData.AddData(data);
            if (bulkData.GetSize() >= bulkSize_)
            {
                Flush(stream);
            }
        }
        /// <summary>
        /// Flushs the data.
        /// </summary>
        /// <param name="stream">
        /// Stream.
        /// </param>
        /// <param name="bulkData">
        /// Bulk data.
        /// </param>
        protected void FlushData(string stream, BulkData bulkData)
        {
            if (bulkData.GetSize() == 0)
            {
                return;
            }

            if (isStreamFlush_.ContainsKey(stream) && isStreamFlush_[stream])
            {
                queueFlush_[stream] = true;
                return;
            }

            isStreamFlush_[stream] = true;

            string   bulkStrData  = bulkData.GetStringData();
            BulkData bulkDataTemp = new BulkData(bulkData);

            int bulkSize = bulkData.GetSize();

            bulkData.ClearData();

            float timeout = retryTimeout_;

            Action <ironsource.Response> callback = null;

            callback = delegate(ironsource.Response response) {
                PrintLog("from callback: status = " + response.status);

                if (response.status <= -1 || response.status >= 500)
                {
                    if (timeout < 20 * 60)
                    {
                        api_.getCoruotinehandler().StartCoroutine(
                            SendData(stream, bulkStrData, bulkSize, HttpMethod.POST, callback, true, timeout));
                        timeout = timeout * 2;
                        return;
                    }
                    else
                    {
                        BulkData currentBulkData = bulkDataMap_[stream];
                        currentBulkData.AddBulkData(bulkDataTemp);

                        callback(new Response("Timeout - No reponse from server", null, 408));
                        return;
                    }
                }

                isStreamFlush_[stream] = false;
                if (queueFlush_.ContainsKey(stream) && queueFlush_[stream])
                {
                    queueFlush_[stream] = false;
                    Flush();
                }
            };

            api_.getCoruotinehandler().StartCoroutine(SendData(stream, bulkStrData, bulkSize, HttpMethod.POST, callback));
        }
Exemple #3
0
        /// <summary>
        /// Adds the bulk data.
        /// </summary>
        /// <param name="data">
        /// Data.
        /// </param>
        public void AddBulkData(BulkData bulkData)
        {
            List <String> bulkDataList = bulkData.GetData();

            foreach (var data in bulkDataList)
            {
                AddData(data);
            }
        }
Exemple #4
0
        public BulkData(BulkData bulkData) :
            this()
        {
            List <String> bulkDataList = bulkData.GetData();

            foreach (var data in bulkDataList)
            {
                AddData(data);
            }
        }
 /// <summary>
 /// Flush the specified stream.
 /// </summary>
 /// <param name="stream">
 /// Stream.
 /// </param>
 public void Flush(string stream)
 {
     if (stream.Length > 0)
     {
         if (bulkDataMap_.ContainsKey(stream))
         {
             BulkData bulkData = bulkDataMap_[stream];
             FlushData(stream, bulkData);
         }
     }
     else
     {
         PrintLog("Wrong stream name!");
     }
 }