private Guid logicalEndpointSetID; // The current logical endpoint set ID /// <summary> /// Constructor. /// </summary> /// <param name="routerEP">The router endpoint.</param> /// <param name="appName">The name of the application hosting the router.</param> /// <param name="appDescription">A description of the application.</param> /// <param name="routerInfo">The router's capability information.</param> /// <param name="logicalEndpointSetID">The router's logical endpoint set ID.</param> /// <param name="udpEP">The UDP network endpoint (or <c>null</c>).</param> /// <param name="tcpEP">The TCP network endpoint (or <c>null</c>).</param> /// <param name="ttd">Route time-to-die (SYS).</param> /// <remarks> /// The router endpoint must be a physical non-channel endpoint. /// </remarks> internal PhysicalRoute(MsgEP routerEP, string appName, string appDescription, MsgRouterInfo routerInfo, Guid logicalEndpointSetID, IPEndPoint udpEP, IPEndPoint tcpEP, DateTime ttd) { Assertion.Test(routerEP.IsPhysical); Assertion.Test(!routerEP.IsChannel); this.routerEP = routerEP; this.appName = appName; this.appDescription = appDescription; this.routerInfo = routerInfo; this.logicalEndpointSetID = logicalEndpointSetID; this.udpEP = udpEP == null ? null : new ChannelEP(Transport.Udp, udpEP); this.tcpEP = tcpEP == null ? null : new ChannelEP(Transport.Tcp, tcpEP); this.ttd = ttd; this.isP2P = routerInfo.IsP2P; }
/// <summary> /// Adds or refreshes the physical route to a peer or child router. /// </summary> /// <param name="routerEP">The router's physical endpoint.</param> /// <param name="appName">Name of the application hosting the router.</param> /// <param name="appDescription">Description of the hosting appplication.</param> /// <param name="routerInfo">The router's capability information.</param> /// <param name="logicalEndpointSetID">The router's logical endpoint set ID.</param> /// <param name="udpEP">The router's UDP endpoint.</param> /// <param name="tcpEP">The router's TCP endpoint.</param> /// <remarks> /// <note> /// The router's endpoint must be a direct descendant of /// the associated router's endpoint or a peer in the physical /// hierarchy. /// </note> /// </remarks> public void Add(MsgEP routerEP, string appName, string appDescription, MsgRouterInfo routerInfo, Guid logicalEndpointSetID, IPEndPoint udpEP, IPEndPoint tcpEP) { PhysicalRoute route; string ep; DateTime TTD; if (!routerEP.IsPhysical || routerEP.IsChannel) { throw new ArgumentException("Only physical non-channel endpoints may be added to a PhysicalRouteTable."); } if (!router.RouterEP.IsPhysicalPeer(routerEP) && (!router.RouterEP.IsPhysicalDescendant(routerEP) || router.RouterEP.Segments.Length + 1 != routerEP.Segments.Length)) { throw new ArgumentException("Only peer or direct child endpoints may be added to a PhysicalRouteTable."); } ep = routerEP.ToString(-1, false); TTD = SysTime.Now + routeTTL; using (TimedLock.Lock(router.SyncRoot)) { routes.TryGetValue(ep, out route); if (route == null) { routes.Add(ep, new PhysicalRoute(routerEP, appName, appDescription, routerInfo, logicalEndpointSetID, udpEP, tcpEP, TTD)); } else { route.LogicalEndpointSetID = logicalEndpointSetID; route.UdpEP = udpEP == null ? null : new ChannelEP(Transport.Udp, udpEP); route.TcpEP = tcpEP == null ? null : new ChannelEP(Transport.Tcp, tcpEP); route.TTD = TTD; router.Trace(1, "KeepAlive", "ep=" + ep.ToString() + " TTD=" + TTD.ToString() + " RTTD=" + route.TTD.ToString(), null); } } }