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