Exemplo n.º 1
0
        public override void Handle(Peer peer)
        {
            peer.Session.Send(new HelloMessage() { Node = peer.Self.Self });
            HelloMessage response = peer.Session.Receive<HelloMessage>();
            peer.Node = response.Node;

            peer.State = new TwoWayState();
            peer.State.Handle(peer);
        }
Exemplo n.º 2
0
 public override void Handle(Peer peer)
 {
     if (peer.Initiatior)
     {
         peer.State = new ExStartState();
         peer.State.Handle(peer);
     }
     else
     {
         peer.State = new ExchangeState();
         peer.State.Handle(peer);
     }
 }
Exemplo n.º 3
0
        public override void Handle(Peer peer)
        {
            if (peer.Initiatior)
            {
                peer.State = new AttemptState();
                peer.State.Handle(peer);
                return;
            }

            HelloMessage response = peer.Session.Receive<HelloMessage>();
            peer.Node = response.Node;

            peer.State = new InitState();
            peer.State.Handle(peer);
        }
Exemplo n.º 4
0
 public override void Handle(Peer peer)
 {
     //Send Peers
     peer.Session.Send(new LinkStateUpdateMessage() { Initial = true, Neighbors = peer.Self.EstablishedPeers.Values.Select(p => p.Node).ToList(), SerialNumber = 1});
     
     if (peer.Initiatior)
     {
         peer.State = new ExchangeState();
         peer.State.Handle(peer);
     }
     else
     {
         peer.State = new LoadingState();
         peer.State.Handle(peer);
     }
 }
Exemplo n.º 5
0
 public override void Handle(Peer peer)
 {
     peer.Session.Send(new HelloMessage() { Node = peer.Self.Self });
     peer.State = new TwoWayState();
     peer.State.Handle(peer);
 }
Exemplo n.º 6
0
 public abstract void Handle(Peer peer);
Exemplo n.º 7
0
 public override void Handle(Peer peer)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
 public override void Handle(Peer peer)
 {
     while (peer.Session.IsConnected)
     {
         
     }
     Console.WriteLine("Peer: {0} <-> {1}", peer.Self.Self.Id, peer.Node.Id);
 }
Exemplo n.º 9
0
        public override void Handle(Peer peer)
        {
            //Add neig
            while (!peer.Neighbors.IsEmpty)
            {
                Node newNeighbor;
                if(peer.Neighbors.TryDequeue(out newNeighbor))
                    peer.Self.AddNode(newNeighbor);
            }

            peer.State = new FullState();
            peer.State.Handle(peer);
        }
Exemplo n.º 10
0
        public override void Handle(Peer peer)
        {
            var linkStateUpdateMessage = peer.Session.Receive<LinkStateUpdateMessage>();

            if (linkStateUpdateMessage.Initial)
            {
                peer.SerialNumber = linkStateUpdateMessage.SerialNumber;
            }

            if (linkStateUpdateMessage.SerialNumber > peer.SerialNumber)
            {
                try
                {
                    foreach (Node neighbor in linkStateUpdateMessage.Neighbors)
                    {
                        peer.Neighbors.Enqueue(neighbor);
                    }
                }
                finally
                {
                    peer.SerialNumber = linkStateUpdateMessage.SerialNumber;
                }
            }

            if (peer.Initiatior)
            {
                peer.State = new LoadingState();
                peer.State.Handle(peer);
            }
            else
            {
                peer.State = new ExStartState();
                peer.State.Handle(peer);
            }
        }