/// <summary> /// envia un mensaje troceado en paquetes /// </summary> internal object BeginSend_tt(object state) { Route route = null; bool success = true; Exception exception = null; SendItemThread tmp = (SendItemThread)state; NodeBind source = tmp.source; NodeBind dest = tmp.dest; Message msg = tmp.msg; RouteContCallback cb = tmp.cb; try { // firewall if (localNode.blockedAddresses.IndexOf(dest.NodeId) > -1) { throw new Exception("Dirección bloqueada"); } // conseguir la ruta para mandar los datos al destino route = localNode.RouteTable.GetRoute(dest.NodeAddress); byte[] buf = new byte[8192]; int bytesRead; IHttpMessage httpMsg = msg.Serialize(); using (var sourceStream = new HttpSenderStream(httpMsg)) { sourceStream.Position = 0; // copy all data from in to out via the buffer layer while ((bytesRead = sourceStream.Read(buf, 0, buf.Length)) > 0 && !msg.Cancelled) { route.Send(buf, 0, bytesRead); totalBytesSent += (uint)bytesRead; } if (msg.Cancelled) { Node.LogAppendLine("Envio cancelado {0}"); } } } catch (Exception err) { exception = err; success = false; } finally { try { // llamamos al callback if (cb != null) { cb(localNode, msg, route, success, exception); } } catch { } } return(null); }