Exemple #1
0
 public static OutboundSocketAction Send(TransportMessage message, IEnumerable <Peer> peers, SendContext context)
 => new OutboundSocketAction(message, peers, context);
Exemple #2
0
 private OutboundSocketAction(TransportMessage message, IEnumerable <Peer> targets, SendContext context)
 {
     Message = message;
     Targets = targets as List <Peer> ?? targets.ToList();
     Context = context;
 }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
 public void Send(TransportMessage message, IEnumerable <Peer> peers, SendContext context)
 {
     _outboundSocketActions.Add(OutboundSocketAction.Send(message, peers, context));
 }
Exemple #5
0
 private OutboundSocketAction(TransportMessage message, IEnumerable <Peer> targets, SendContext context)
 {
     Message  = message;
     _targets = targets;
     _context = context;
 }
Exemple #6
0
        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);
            }
        }