protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result) { if (result.Type == ResultType.SimpleString && result.IsEqual(QUEUED)) { var q = message as QueuedMessage; if (q != null) { q.WasQueued = true; } return(true); } return(false); }
protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result) { var tran = message as TransactionMessage; if (tran != null) { var bridge = connection.Bridge; var wrapped = tran.InnerOperations; switch (result.Type) { case ResultType.SimpleString: if (tran.IsAborted && result.IsEqual(RedisLiterals.BytesOK)) { connection.Multiplexer.Trace("Acknowledging UNWATCH (aborted electively)"); SetResult(message, false); return(true); } //EXEC returned with a NULL if (!tran.IsAborted && result.IsNull) { connection.Multiplexer.Trace("Server aborted due to failed EXEC"); //cancel the commands in the transaction and mark them as complete with the completion manager foreach (var op in wrapped) { op.Wrapped.Cancel(); bridge.CompleteSyncOrAsync(op.Wrapped); } SetResult(message, false); return(true); } break; case ResultType.MultiBulk: if (!tran.IsAborted) { var arr = result.GetItems(); if (arr == null) { connection.Multiplexer.Trace("Server aborted due to failed WATCH"); foreach (var op in wrapped) { op.Wrapped.Cancel(); bridge.CompleteSyncOrAsync(op.Wrapped); } SetResult(message, false); return(true); } else if (wrapped.Length == arr.Length) { connection.Multiplexer.Trace("Server committed; processing nested replies"); for (int i = 0; i < arr.Length; i++) { if (wrapped[i].Wrapped.ComputeResult(connection, arr[i])) { bridge.CompleteSyncOrAsync(wrapped[i].Wrapped); } } SetResult(message, true); return(true); } } break; } // even if we didn't fully understand the result, we still need to do something with // the pending tasks foreach (var op in wrapped) { op.Wrapped.Fail(ConnectionFailureType.ProtocolFailure, null); bridge.CompleteSyncOrAsync(op.Wrapped); } } return(false); }