public static OutboundSocketAction Send(TransportMessage message, IEnumerable <Peer> peers, SendContext context) => new OutboundSocketAction(message, peers, context);
private OutboundSocketAction(TransportMessage message, IEnumerable <Peer> targets, SendContext context) { Message = message; Targets = targets as List <Peer> ?? targets.ToList(); Context = context; }
private void WriteTransportMessageAndSendToPeers(TransportMessage transportMessage, List <Peer> peers, SendContext context, CodedOutputStream outputStream) { outputStream.Reset(); outputStream.WriteTransportMessage(transportMessage, _environment); if (context.PersistencePeer == null && transportMessage.IsPersistTransportMessage) { outputStream.WritePersistentPeerIds(transportMessage, transportMessage.PersistentPeerIds); } foreach (var target in peers) { var isPersistent = context.WasPersisted(target.Id); outputStream.SetWasPersisted(isPersistent); SendToPeer(transportMessage, outputStream, target); } if (context.PersistencePeer != null) { outputStream.WritePersistentPeerIds(transportMessage, context.PersistentPeerIds); SendToPeer(transportMessage, outputStream, context.PersistencePeer); } }
public void Send(TransportMessage message, IEnumerable <Peer> peers, SendContext context) { _outboundSocketActions.Add(OutboundSocketAction.Send(message, peers, context)); }
private OutboundSocketAction(TransportMessage message, IEnumerable <Peer> targets, SendContext context) { Message = message; _targets = targets; _context = context; }
private void WriteTransportMessageAndSendToPeers(TransportMessage transportMessage, List <Peer> peers, SendContext context, ProtoBufferWriter bufferWriter) { bufferWriter.Reset(); bufferWriter.WriteTransportMessage(transportMessage, _environment); if (context.PersistencePeer == null && transportMessage.IsPersistTransportMessage) { bufferWriter.WritePersistentPeerIds(transportMessage, transportMessage.PersistentPeerIds); } foreach (var target in peers) { var isPersistent = context.WasPersisted(target.Id); bufferWriter.SetWasPersisted(isPersistent); SendToPeer(transportMessage, bufferWriter, target); } if (context.PersistencePeer != null) { bufferWriter.WritePersistentPeerIds(transportMessage, context.PersistentPeerIds); SendToPeer(transportMessage, bufferWriter, context.PersistencePeer); } }