Ejemplo n.º 1
0
        private TcsWrappedBootstrap <Task> BootstrapPing(PeerAddress address)
        {
            var tcsBootstrap = new TcsWrappedBootstrap <Task>();

            var taskPing = _peer.Ping().SetPeerAddress(address).SetIsTcpPing().Start();

            taskPing.ContinueWith(tp =>
            {
                if (!tp.IsFaulted)
                {
                    PeerAddress = tp.Result;
                    BootstrapTo = new List <PeerAddress>(1)
                    {
                        PeerAddress
                    };
                    tcsBootstrap.SetBootstrapTo(BootstrapTo);
                    tcsBootstrap.WaitFor(Bootstrap().Task);
                }
                else
                {
                    tcsBootstrap.SetException(new TaskFailedException("Could not reach anyone with bootstrap."));
                }
            });

            return(tcsBootstrap);
        }
Ejemplo n.º 2
0
        private TcsWrappedBootstrap <Task> Bootstrap()
        {
            var tcsBootstrap = new TcsWrappedBootstrap <Task>();

            tcsBootstrap.SetBootstrapTo(BootstrapTo);

            int conn   = RoutingConfiguration.Parallel;
            var taskCc = _peer.ConnectionBean.Reservation.CreateAsync(conn, 0);

            Utils.Utils.AddReleaseListener(taskCc, tcsBootstrap.Task);
            taskCc.ContinueWith(tcc =>
            {
                if (!tcc.IsFaulted)
                {
                    var routingBuilder    = CreateBuilder(RoutingConfiguration, IsForceRoutingOnlyToSelf);
                    var taskBootstrapDone = _peer.DistributedRouting.Bootstrap(BootstrapTo, routingBuilder, tcc.Result);
                    tcsBootstrap.WaitFor(taskBootstrapDone);
                }
                else
                {
                    tcsBootstrap.SetException(tcc.TryGetException());
                }
            });

            return(tcsBootstrap);
        }
Ejemplo n.º 3
0
        private TcsWrappedBootstrap <Task> Broadcast0()
        {
            var tcsBootstrap = new TcsWrappedBootstrap <Task>();

            var taskPing = _peer.Ping().SetIsBroadcast().SetPort(PortUdp).Start();

            taskPing.ContinueWith(tp =>
            {
                if (!tp.IsFaulted)
                {
                    PeerAddress = tp.Result;
                    BootstrapTo = new List <PeerAddress>(1)
                    {
                        PeerAddress
                    };
                    tcsBootstrap.SetBootstrapTo(BootstrapTo);
                    tcsBootstrap.WaitFor(Bootstrap().Task);
                }
                else
                {
                    tcsBootstrap.SetException(new TaskFailedException("Could not reach anyone with the broadcast. " + tp.TryGetException()));
                }
            });

            return(tcsBootstrap);
        }