private void HandleAnnouncement(UdpClientRemoteInfo remoteInfo, AnnouncementDto x)
        {
            announcementsReceivedCounter.Increment();

            var            peerIdentity           = x.Identity;
            var            peerId                 = peerIdentity.Id;
            bool           isNewlyDiscoveredRoute = false;
            RoutingContext addedRoutingContext    = null;
            UdpUnicaster   addedUnicaster         = null;
            var            routingContext         = routingContextsByPeerId.GetOrAdd(
                peerId,
                add => {
                isNewlyDiscoveredRoute = true;
                var unicastReceivePort = int.Parse((string)x.Identity.Properties[UdpConstants.kUnicastPortIdentityPropertyKey]);
                var unicastIpAddress   = remoteInfo.IPEndpoint.Address;
                var unicastEndpoint    = new IPEndPoint(unicastIpAddress, unicastReceivePort);
                var unicastRemoteInfo  = new UdpClientRemoteInfo {
                    Socket     = remoteInfo.Socket,
                    IPEndpoint = unicastEndpoint
                };

                addedUnicaster = udpUnicasterFactory.Create(unicastRemoteInfo);
                return(addedRoutingContext = new RoutingContext(addedUnicaster));
            });

            if (addedRoutingContext == routingContext)
            {
                addedUnicaster.Initialize();
            }
            if (isNewlyDiscoveredRoute)
            {
                routingTable.Register(peerId, routingContext);
            }

            peerTable.GetOrAdd(peerId).HandleInboundPeerIdentityUpdate(peerIdentity);
        }
 public RoutingContext(UdpUnicaster unicaster)
 {
     this.unicaster = unicaster;
 }