Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
            }
        }