private void CreateRemoteEdge(SimulationEdge se_l) { int remote_id = se_l.RemoteID; var el_map = GetEdgeListenerList(TAType); if(!el_map.ContainsKey(remote_id)) { return; } var remote = el_map[remote_id]; if(!remote.Nat.AllowingIncomingConnections) { return; } // Make sure that the remote listener does not deny our TAs. foreach (TransportAddress ta_local in LocalTAs) { if (remote.TAAuth.Authorize(ta_local) == TAAuthorizer.Decision.Deny ) { return; } } SimulationEdge se_r = new SimulationEdge(remote, remote_id, LocalID, true, se_l.Delay, _ta_type); remote.AddEdge(se_r); se_l.Partner = se_r; se_r.Partner = se_l; remote.SendEdgeEvent(se_r); }
/* * Implements the EdgeListener function to * create edges of this type. */ public override void CreateEdgeTo(TransportAddress ta, EdgeCreationCallback ecb) { if( !IsStarted ) { // it should return null and not throw an exception // for graceful disconnect and preventing others to // connect to us after we've disconnected. ecb(false, null, new EdgeException("Not started")); return; } else if( ta.TransportAddressType != this.TAType ) { //Can't make an edge of this type ecb(false, null, new EdgeException("Can't make edge of this type")); return; } else if( _ta_auth.Authorize(ta) == TAAuthorizer.Decision.Deny ) { //Not authorized. Can't make this edge: ecb(false, null, new EdgeException( ta.ToString() + " is not authorized") ); return; } int remote_id = ((SimulationTransportAddress) ta).ID; int real_remote_id = (remote_id >= 0) ? remote_id : ~remote_id; //Outbound edge: int delay = 0; if(_use_delay) { if(LatencyMap != null) { int local = LocalID % LatencyMap.Count; int remote = real_remote_id % LatencyMap.Count; delay = LatencyMap[local][remote] / 1000; } else { delay = 100; } } SimulationEdge se_l = new SimulationEdge(this, LocalID, remote_id, false, delay, _ta_type); if(real_remote_id == remote_id) { CreateRemoteEdge(se_l); } ecb(true, se_l, null); }