public void AddTransaction(string id, object data, object request = null, int timeOut = 0) { if (this._transactions.ContainsKey(id)) { throw new UnityEngine.UnityException("Transaction [" + id + "] already exists in _transactions"); } Transaction transaction = new Transaction(); transaction.id = id; transaction.data = data; transaction.request = request; transaction.status = transactionStatus.added; transaction.timeStart = Ucss.Common.GetSeconds(); transaction.timeOut = timeOut; this._transactions.Add(id, transaction); this._transactionsQueue.Enqueue(id); }
protected void OnTimeOut(Transaction transaction) { HTTPRequest request = (HTTPRequest)transaction.request; if (!string.IsNullOrEmpty(request.transactionId)) { if (request.onTimeOut != null) { request.onTimeOut(transaction.id); return; } if (request.onError != null) { request.onError("timeout", transaction.id); return; } if (this._onErrorCallback != null) { this._onErrorCallback("timeout", transaction.id); return; } throw new UnityEngine.UnityException("Transaction [" + transaction.id + "] time out, but no callbacks for it"); } else { throw new UnityEngine.UnityException("Transaction [" + transaction.id + "] time out, but [request] is null"); } }