/// <summary> /// Called by a reply message when it arrives at the original source. /// </summary> /// <param name="reply"></param> public void ReceivedReply(OverlayReply reply) { // Get the request's nodeId string id = reply.RequestId; // Look up the request's nodeId in the table. if (table.ContainsKey(id)) { // Get the entry for this nodeId TableEntry entry = (TableEntry)table[id]; if (entry.request == null) { // If there is no request message, this node is not the source } else { OverlayRequest request = entry.request; // calculate duration entry.durationRequest = DateTime.Now.Subtract(entry.insertedTime); // Cancel the pending timer. localNode.CancelTimer(entry.replyTimer); if (request.Async != null) { // todo realizado adecuadamente request.Async.success = true; // comprobamos que nos hayan enviado un error if (reply is OverlayError) { OverlayError overlayErr = (OverlayError)reply; request.Async.success = false; request.Async.exception = overlayErr.GetException(); } else { request.Async.Reply = reply; } // ejecutamos el callback ExecuteCallback(request); } // Remove the entry from the table RemoveEntry(id); } } }
//********************************************************************************************** // Replies //********************************************************************************************** /// <summary> /// Add a reply to the table. /// </summary> public void AddReply(NodeBind dest, OverlayReply reply) { // Get the table entry for this request nodeId (which should already exist) string id = reply.RequestId; if (table.ContainsKey(id)) { // Stick this reply into the table entry TableEntry entry = (TableEntry)table[id]; Debug.Assert(entry.reply == null); entry.reply = reply; entry.replyDest = dest; // la variable q dice si la entrada se ha insertado o no // se marca cuando sale el mensaje; si el mensaje se envia // al mismo nodo del que salio esta varible es igual a true // por lo que no debemos borrar la entrada por que se necesita // para recibir la replica if (!entry.insertedTable) { // cancelamos el timer localNode.CancelTimer(entry.gcTimer); // sino la eliminamos aqui habría que esperar al GC // porque si el mismo nodo nos quiere enviar peticiones // coincidirian con nodeId de peticiones anteriores RemoveEntry(id); } } else { // No entry in the table. // This can occur if AllowDupCCR / AllowDupAD are true // Don't keep track of the reply } }